/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define PI 3.1415926535
#define pb push_back
#define setp() cout << setprecision(15)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " is " << x << '\n';
const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20;
int n, m, ans[N];
pair<pair<int, int>, int> arr[N];
vector<bool> a, b;
void solve(){
cin >> n >> m;
for(int i = 0; i < m; ++i) cin >> arr[i].first.first >> arr[i].first.second;
for(int i = 0; i < m; ++i) arr[i].second = i;
sort(arr, arr+m);
int l = 0, l1 = 0;
a.resize(n + 1);
b.resize(n + 1);
for(int i = 0; i < m; ++i){
if(arr[i].first.second > l){
ans[arr[i].second] = 1;
while(l < arr[i].first.second) a[l] = 1, l++;
a[l] = 1;
}
else{
ans[arr[i].second] = 0;
while(l1 < arr[i].first.second) b[l1] = 1, l1++;
b[l1] = 1;
}
}
bool ok = 1;
for(int i = 1; i <= n; ++i) ok &= a[i] & b[i];
if(ok) for(int i = 0; i < m; ++i) cout << ans[i];
else cout << "impossible";
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
int T = 1, aa;
// cin >> T;aa=T;
while(T--){
// cout << "Case #" << aa-T << ": ";
solve();
cout << '\n';
}
return 0;
}
Compilation message
alternating.cpp: In function 'int main()':
alternating.cpp:52:16: warning: unused variable 'aa' [-Wunused-variable]
52 | int T = 1, aa;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
0 ms |
332 KB |
'impossible' claimed, but there is a solution |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
0 ms |
332 KB |
'impossible' claimed, but there is a solution |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
0 ms |
332 KB |
'impossible' claimed, but there is a solution |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
2764 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
9 ms |
1600 KB |
Output is correct |
4 |
Incorrect |
11 ms |
1748 KB |
no wires in direction 0 between segments 1 and 1 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
0 ms |
332 KB |
'impossible' claimed, but there is a solution |
4 |
Halted |
0 ms |
0 KB |
- |