Submission #26364

#TimeUsernameProblemLanguageResultExecution timeMemory
26364youngyojunIli (COI17_ili)C++11
0 / 100
0 ms2144 KiB
/// 010-5330-7849 #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <iostream> #include <algorithm> #include <vector> #include <stack> #include <deque> #include <queue> #include <set> #include <map> #include <unordered_map> #include <bitset> #include <string> #include <tuple> #define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x); #define pb push_back #define sz(V) ((int)(V).size()) #define allv(V) ((V).begin()),((V).end()) #define befv(V) ((V)[(sz(V)-2)]) #define sorv(V) sort(allv(V)) #define revv(V) reverse(allv(V)) #define univ(V) (V).erase(unique(allv(V)),(V).end()) #define clv(V) (V).clear() #define upmin(a,b) (a)=min((a),(b)) #define upmax(a,b) (a)=max((a),(b)) #define rb(x) ((x)&(-(x))) #define INF (0x3f3f3f3f) #define INFLL (0x3f3f3f3f3f3f3f3fll) #define MAXN (10005) #define MAXM (10005) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<int, ll> pil; typedef pair<ll, int> pli; char A[MAXM][2]; int B[MAXM][2]; char C[MAXM], D[MAXN]; char str[MAXM]; int N, M; char& read(char x, int i) { return ('x' == x) ? D[i] : C[i]; } char& read(int i, int j) { return read(A[i][j], B[i][j]); } bool f() { for(int i = 1; i <= M; i++) C[i] = str[i]; fill(D+1, D+N+1, '?'); for(int i = M; i; i--) { if('0' == C[i]) { if('1' == read(i, 0) || '1' == read(i, 1)) return false; read(i, 0) = read(i, 1) = '0'; } else if('1' == C[i]) { if('0' == read(i, 0) && '0' == read(i, 1)) return false; if('0' == read(i, 0)) read(i, 1) = '1'; else if('0' == read(i, 1)) read(i, 0) = '1'; } } for(int i = 1; i <= M; i++) { if('0' == C[i]) { if('1' == read(i, 0) || '1' == read(i, 1)) return false; read(i, 0) = read(i, 1) = '0'; } else if('1' == C[i]) { if('0' == read(i, 0) && '0' == read(i, 1)) return false; if('?' == read(i, 0)) read(i, 0) = '1'; if('?' == read(i, 1)) read(i, 1) = '1'; } else { if('0' == read(i, 0) && '0' == read(i, 0)) C[i] = '0'; else { if('?' == read(i, 0)) read(i, 0) = '1'; if('?' == read(i, 1)) read(i, 1) = '1'; C[i] = '1'; } } } return true; } int main() { scanf("%d%d %s", &N, &M, str+1); for(int i = 1; i <= M; i++) { for(int j = 0; j < 2; j++) { scanf(" %c%d", &A[i][j], &B[i][j]); } } for(int i = 1; i <= M; i++) { if('?' != str[i]) { putchar(str[i]); continue; } str[i] = '0'; bool bumsoo1 = f(); str[i] = '1'; bool bumsoo2 = f(); str[i] = '?'; if(bumsoo1 && !bumsoo2) putchar('0'); else if(!bumsoo1 && bumsoo2) putchar('1'); else putchar('?'); } putchar('\n'); return 0; }

Compilation message (stderr)

ili.cpp: In function 'int main()':
ili.cpp:83:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d %s", &N, &M, str+1);
                                 ^
ili.cpp:86:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c%d", &A[i][j], &B[i][j]);
                                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...