Submission #171292

#TimeUsernameProblemLanguageResultExecution timeMemory
171292mehrdad_sohrabiAlternating Current (BOI18_alternating)C++14
0 / 100
3008 ms2040 KiB
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; #define pb push_back #define pii pair < ll , ll > #define F first #define S second #define endl '\n' #define int long long #define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") using namespace std; /// khodaya komak kon /// ya navid navid const int N=1e5+100; int n, m, L[N], R[N]; bool M[N][2]; string S(int mask) { string s = ""; for (int i = 0; i < m; i++) s += '0' + ((mask >> i) & 1); return s; } int32_t main() { sync; ll n,m; cin >> n >> m; for (int i = 0; i < m; i++) cin >> L[i] >> R[i], L[i]--, R[i]--; for (int mask = 0; mask < (1 << m); mask++) { for (int i = 0; i < n; i++) M[i][0] = M[i][1] = false; for (int i = 0; i < m; i++) { for (int j = L[i]; j != R[i]; j = (j + 1) % n) M[j][(mask >> i) & 1] = true; M[R[i]][(mask >> i) & 1] = true; } bool flag = true; for (int i = 0; i < n; i++) flag &= M[i][0] & M[i][1]; if (flag){ S(mask); return 0; } } cout << "impossible" << endl; return 0; }
#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...