Submission #171300

#TimeUsernameProblemLanguageResultExecution timeMemory
171300AtalasionAlternating Current (BOI18_alternating)C++14
13 / 100
3029 ms3740 KiB
//khodaya khodet komak kon #include <bits/stdc++.h> #define F first #define S second #define pb push_back #define all(x) x.begin(), x.end() #pragma GCC optimise ("ofast") #pragma GCC optimise("unroll-loops") using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; const int N = 200000 + 10; const ll MOD = 1000000000 + 7; const ll INF = 1000000000000000000; const ll LOG = 25; int n, m, cnt[N], cnt2[N]; vector<pii> Q; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= m; i++){ int l, r; cin >> l >> r; Q.pb({l, r}); } for (int mask = 0; mask < (1 << m); mask ++){ memset(cnt, 0, sizeof cnt); memset(cnt2, 0, sizeof cnt2); for (int i = 0; i < m; i++){ if (mask & (1 << i)){ if (Q[i].F > Q[i].S){ for (int j = Q[i].F; j <= n; j++){ cnt[j] ++; } for (int j = 1; j <= Q[i].S; j++) cnt[j]++; }else{ for (int j = Q[i].F; j <= Q[i].S; j++) cnt[j]++; } }else{ if (Q[i].F > Q[i].S){ for (int j = Q[i].F; j <= n; j++){ cnt2[j] ++; } for (int j = 1; j <= Q[i].S; j++) cnt2[j]++; }else{ for (int j = Q[i].F; j <= Q[i].S; j++) cnt2[j]++; } } } bool f = 1; for (int i = 1; i <= n; i++){ if (cnt[i] == 0 || cnt2[i] == 0) f = 0; } if (f){ for (int i = 0; i < m; i++) cout << ((mask & (1 << i)) != 0); return 0; } } cout << "impossible"; return 0; }

Compilation message (stderr)

alternating.cpp:8:0: warning: ignoring #pragma GCC optimise [-Wunknown-pragmas]
 #pragma GCC optimise ("ofast")
 
alternating.cpp:9:0: warning: ignoring #pragma GCC optimise [-Wunknown-pragmas]
 #pragma GCC optimise("unroll-loops")
#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...