Submission #63052

# Submission time Handle Problem Language Result Execution time Memory
63052 2018-07-31T12:59:17 Z zetapi Alternating Current (BOI18_alternating) C++14
0 / 100
3000 ms 4460 KB
#include <bits/stdc++.h>
using namespace std;

#define pb  push_back
#define mp  make_pair
#define int long long
#define itr ::iterator 

typedef pair<int,int>  pii;

const int MAX=1e5;

int N,M,X[MAX],Y[MAX],mark[MAX][2];

bool ok(int mask)
{
	for(int A=0;A<N;A++)
	{
		mark[A][0]=0;
		mark[A][1]=0;
	}
	for(int A=0;A<M;A++)
	{
		if(X[A]>Y[A])
		{
			for(int B=X[A];B<N;B++)
				mark[B][((mask&(1<<A))!=0)]=1;
			for(int B=0;B<X[A];B++)
				mark[B][((mask&(1<<A))!=0)]=1;
		}
		else
		{
			for(int B=X[A];B<=Y[A];B++)
				mark[B][((mask&(1<<A))!=0)]=1;
		}
	}
	for(int A=0;A<N;A++)
		if(mark[A][0]+mark[A][1]!=2)
			return false;
	return true;
}

signed main()
{
	ios_base::sync_with_stdio(false);

	cin>>N>>M;
	for(int A=0;A<M;A++)
	{
		cin>>X[A]>>Y[A];
		X[A]--;
		Y[A]--;
	}
	string res="";
	for(int A=0;A<(1<<M);A++)
	{
		if(ok(A))
		{
			for(int C=0;C<M;C++)
				res+=(char)(((A&(1<<C))!=0)?1:0)+'0';
			cout<<res;
			return 0;
		}
	}
	cout<<"impossible";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
3 Incorrect 3 ms 452 KB no wires in direction 1 between segments 7 and 12
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
3 Incorrect 3 ms 452 KB no wires in direction 1 between segments 7 and 12
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
3 Incorrect 3 ms 452 KB no wires in direction 1 between segments 7 and 12
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3022 ms 4460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
3 Incorrect 3 ms 452 KB no wires in direction 1 between segments 7 and 12
4 Halted 0 ms 0 KB -