Submission #646303

#TimeUsernameProblemLanguageResultExecution timeMemory
646303mychecksedadAlternating Current (BOI18_alternating)C++17
0 / 100
21 ms2008 KiB
/* 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; bool comp(pair<pair<int, int>, int> &a, pair<pair<int, int>, int> &b){ if(a.first.first == b.first.first) return a.first.second < b.first.second; return a.first.first > b.first.first; } 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, comp); 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){ if(arr[i].first.first > l + 1){ cout << "impossible"; return; } ans[arr[i].second] = 1; while(l < arr[i].first.second) a[l] = 1, l++; a[l] = 1; } else{ if(arr[i].first.first > l1 + 1){ cout << "impossible"; return; } 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 (stderr)

alternating.cpp: In function 'int main()':
alternating.cpp:63:16: warning: unused variable 'aa' [-Wunused-variable]
   63 |     int T = 1, aa;
      |                ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...