CSES - Datatähti Open 2017 - Results
Submission details
Task:Family reunion
Sender:zscoder
Submission time:2017-01-21 12:21:47 +0200
Language:C++
Status:READY
Result:19
Feedback
groupverdictscore
#1UNKNOWN0
#2UNKNOWN0
#3UNKNOWN0
Test results
testverdicttimegroup
#1UNKNOWN--1details
#2UNKNOWN--2details
#3UNKNOWN--3details

Code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int a[1001][18];
char z[3] = {'A','B','C'};
bool used[1001];

bool special(int x)
{
	if(x%4==0) return 1;
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m,k; cin>>n>>m>>k;
	for(int j = 0; j < m; j++)
	{
		for(int i = 0; i < 2*k + 1; i++)
		{
			cin>>a[j][i];
		}
	}
	if(m==1)
	{
		for(int i = 0; i < m; i++)
		{
			vi vec(2*k+2);
			for(int j = 0; j < 2*k + 1; j++)
			{
				used[a[i][j]]=1;
				vec[j]=a[i][j];
			}
			for(int j = 1; j <= n; j++)
			{
				if(!used[j]) vec[2*k+1] = j;
			}
			int dist = 0;
			int ptr = k;
			while(vec[ptr]!=1)
			{
				ptr++;
				dist++;
				if(ptr>=2*k+2) ptr=0;
			}
			cout<<z[dist%2]<<'\n';
		}
		return 0;
	}
	{
		int C = 3;
		for(int i = 0; i < m; i++)
		{
			int hsh = 0;
			for(int l = 0; l < 1; l++)
			{
				int dist = k + a[i][k];
				for(int j = k - 1; j >= 0; j--)
				{
					if(a[i][j]%C==1)
					{
						dist=min(dist,k-j); break;
					}
				}
				int dist2 = k;
				for(int j = k + 1; j <= 2*k; j++)
				{
					if(a[i][j]%C==2)
					{
						dist=min(dist,j-k); break;
					}
				}
				hsh+=abs(dist-dist2);
			}
			/*
			for(int l = 0; l < C; l++)
			{
				int dist = k + 1;
				for(int j = k + 1; j <= 2*k; j++)
				{
					if(a[i][j]%C==l)
					{
						dist=min(dist,j-k); break;
					}
				}
				hsh-=dist;
			}
			*/
			/*
			int dist2 = 1001;
			for(int j = k + 1; j <= 2*k; j++)
			{
				if(special(j))
				{
					dist2=min(dist2,j-k); break;
				}
			}
			int hsh = abs(dist1-dist2)%3;
			*/
			hsh%=3;
			if(hsh<0) hsh+=3;
			cout<<z[hsh]<<'\n';
		}
	}
}

Test details

Test 1

Group: 1

Verdict: UNKNOWN

input
#!/bin/bash
set -e
OFFSET=$(grep -onam1 '^__DATA_...

correct output
50

user output
(not available)

Test 2

Group: 2

Verdict: UNKNOWN

input
#!/bin/bash
set -e
OFFSET=$(grep -onam1 '^__DATA_...

correct output
50

user output
(not available)

Test 3

Group: 3

Verdict: UNKNOWN

input
#!/bin/bash
set -e
OFFSET=$(grep -onam1 '^__DATA_...

correct output
50

user output
(not available)