답안 #63054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
63054 2018-07-31T13:02:54 Z zetapi Alternating Current (BOI18_alternating) C++14
0 / 100
3000 ms 3500 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<Y[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]--;
	}
	for(int A=0;A<(1<<M);A++)
	{
		if(ok(A))
		{
			for(int C=0;C<M;C++)
				cout<<(((A&(1<<C))!=0)?1:0);
			return 0;
		}
	}
	cout<<"impossible";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 4 ms 448 KB Output is correct
3 Incorrect 3 ms 528 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 4 ms 448 KB Output is correct
3 Incorrect 3 ms 528 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 4 ms 448 KB Output is correct
3 Incorrect 3 ms 528 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3052 ms 3500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 4 ms 448 KB Output is correct
3 Incorrect 3 ms 528 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -