답안 #657727

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
657727 2022-11-10T21:18:08 Z inksamurai Alternating Current (BOI18_alternating) C++17
0 / 100
16 ms 4948 KB
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _3NRqilq ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
using pii=pair<int,int>;
using vi=vector<int>;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}

#define nare {cout<<"impossible\n";exit(0);}

signed main(){
_3NRqilq;
	int n,m;
	cin>>n>>m;
	vec(vec(pii)) adqry(n);
	rep(i,m){
		int l,r;
		cin>>l>>r;
		assert(l<=r);
		l-=1,r-=1;
		adqry[l].pb({r,i});
	}
	vi pns(m);
	vec(pii) _lst(2);
	// index,id
	_lst[0].se=0;
	_lst[1].se=1;
	rep(i,n){
		rep(j,2){
			if(i>_lst[j].fi){
				nare;
			}
		}
		for(auto p:adqry[i]){
			int r=p.fi;
			int j=p.se;
			if(r>_lst[0].fi){
				swap(_lst[0],_lst[1]);
				_lst[0].fi=r;
				pns[j]=_lst[0].se;
			}else if(r>_lst[1].fi){
				_lst[1].fi=r;
				pns[j]=_lst[1].se;
			}
			if(_lst[0].fi<_lst[1].fi){
				swap(_lst[0],_lst[1]);
			}
		}
	}
	string _s;
	rep(i,m){
		_s+=(char)(pns[i]+'0');
	}
	print(_s);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 4936 KB Output is correct
2 Correct 2 ms 2620 KB Output is correct
3 Correct 13 ms 4948 KB Output is correct
4 Incorrect 11 ms 4948 KB 'impossible' claimed, but there is a solution
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -