Submission #657728

# Submission time Handle Problem Language Result Execution time Memory
657728 2022-11-10T21:23:54 Z inksamurai Alternating Current (BOI18_alternating) C++17
0 / 100
38 ms 7116 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){
		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]);
			}
		}
		rep(j,2){
			if(i>_lst[j].fi){
				nare;
			}
		}
	}
	string _s;
	rep(i,m){
		_s+=(char)(pns[i]+'0');
	}
	print(_s);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 4092 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 11 ms 4436 KB Output is correct
4 Correct 11 ms 4564 KB Output is correct
5 Correct 31 ms 6704 KB Output is correct
6 Correct 26 ms 6476 KB Output is correct
7 Correct 25 ms 6820 KB Output is correct
8 Correct 4 ms 2772 KB Output is correct
9 Correct 2 ms 2516 KB Output is correct
10 Correct 38 ms 6776 KB Output is correct
11 Correct 26 ms 6048 KB Output is correct
12 Correct 30 ms 7116 KB Output is correct
13 Correct 2 ms 2620 KB Output is correct
14 Correct 2 ms 2624 KB Output is correct
15 Incorrect 27 ms 6436 KB no wires in direction 1 between segments 1 and 1
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -