답안 #952870

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
952870 2024-03-25T03:45:12 Z koukirocks Alternating Current (BOI18_alternating) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
 
namespace{using namespace std;}
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MAX=15+10,P=1e9+7;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;
 
int n,m;

struct segment{
	pii rg;
	int id;
}seg[MAX];

int main() {
	speed;
	cin>>n>>m;
	for (int i=0;i<m;i++) {
		cin>>seg[i].rg.F>>seg[i].rg.S;
		seg[i].id=i;
	}
	sort(seg,seg+m,[&](segment a,segment b) {
		if (a.rg.F!=b.rg.F) return a.rg.F<b.rg.F;
		else return a.rg.S>b.rg.S;
	});
	int cvr[2]={0,0};
	int ans=0;
	for (int i=0;i<m;i++) {
		int id;
		if (cvr[0]<cvr[1]) id=0;
		else id=1;
		if (seg[i].rg.F<=cvr[id]+1) {
			cvr[id]=max(cvr[id],seg[i].rg.S);
			if (id==0) ans|=(1<<seg[i].id);
		} else {
			cout<<"impossible\n";
			return 0;
		}
//		cout<<cvr[0]<<" "<<cvr[1]<<"\n";
	}
	for (int i=0;i<m;i++) {
		if (ans&(1<<i)) cout<<"1";
		else cout<<"0";
	}
	return 0;
}

/*
7 6
1 2
1 5
2 3
5 7
6 7
3 4
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 0 is not a string of length exactly 100000
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -