Submission #125014

#TimeUsernameProblemLanguageResultExecution timeMemory
125014Adhyyan1252Ili (COI17_ili)C++11
49 / 100
4025 ms12936 KiB
#include<bits/stdc++.h> using namespace std; #define MAXN 10004 int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m; cin>>n>>m; string me; cin>>me; vector<pair<int, int> > s(m); for(int i = 0; i < m; i++){ char c1, c2; int i1, i2; cin>>c1>>i1>>c2>>i2; i1--, i2--; if(c1 == 'x') i1 = i1*-1 - 1; if(c2 == 'x') i2 = i2*-1 - 1; s[i] = {i1, i2}; } vector<bitset<MAXN> > b(m); for(int i = 0; i < m; i++){ if(s[i].first < 0) b[i].set(s[i].first*-1 - 1); else b[i] |= b[s[i].first]; if(s[i].second < 0) b[i].set(s[i].second*-1 -1); else b[i] |= b[s[i].second]; } bitset<MAXN> zero; for(int i = 0; i < m; i++){ if(me[i] == '0'){ zero |= b[i]; } } zero.flip(); for(int i = 0; i < m; i++){ b[i] &= zero; } vector<int> one; for(int i = 0; i < m; i++){ if(me[i] == '1') one.push_back(i); } for(int i = 0; i < m; i++){ if(me[i] != '?') continue; if(b[i].count() == 0){ me[i] = '0'; continue; } for(int j: one){ if((b[i]&b[j]) == b[j]){ me[i] = '1'; break; } } } cout<<me<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...