Submission #963944

#TimeUsernameProblemLanguageResultExecution timeMemory
963944pccAlternating Current (BOI18_alternating)C++17
13 / 100
3061 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second #define tlll tuple<ll,ll,ll> const int mxn = 16; int N,M; pii arr[mxn]; int ans = -1; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>N>>M; for(int i = 0;i<M;i++){ cin>>arr[i].fs>>arr[i].sc; arr[i].fs--,arr[i].sc--; } for(int i = 0;i<(1<<M);i++){ int dp[mxn] = {}; for(int j = 0;j<M;j++){ int k; for(k = arr[j].fs;k != arr[j].sc;k = (k+1)%N){ dp[k] |= 1<<(i&(1<<j)?1:0); } dp[k] |= 1<<(i&(1<<j)?1:0); } if(*min_element(dp,dp+N) == 3)ans = i; } if(ans == -1)cout<<"impossible\n"; else{ for(int i = 0;i<M;i++){ if(ans&(1<<i))cout<<1; else cout<<0; } } 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...