제출 #1042893

#제출 시각아이디문제언어결과실행 시간메모리
1042893FaggiCoins (IOI17_coins)C++11
100 / 100
7 ms1760 KiB
#include <bits/stdc++.h> using namespace std; std::vector<int> coin_flips(std::vector<int> b, int c) { bool v[7][64],un,x,mal[7],igu=0,mal2[7]; vector<int>flip(0); memset(v,0,sizeof(v)); memset(mal,0,sizeof(mal)); memset(mal2,0,sizeof(mal2)); int i, j,ca,pos=0, bitMal=-1; for(i=1; i<64; i*=2) { ca=0; un=1; x=0; for(j=i; j<=64; j++) { if(ca==i) { un=!un; ca=0; } v[pos][j-1]=un; if(un) x^=b[j-1]; //cout << b[j-1] << ' '; ca++; } //cout << "fin "; mal[pos]=x; //cout << x << endl; pos++; } for(i=0; i<64; i++) { igu=1; for(j=0; j<6; j++) { if(v[j][i]!=mal[j]) { igu=0; break; } } if(igu) { bitMal=i; break; } } //cout << bitMal << endl; if(c==63) { if(bitMal!=-1) { flip.push_back(bitMal); } } else if(bitMal==-1) { flip.push_back(c); } else if(bitMal!=c) { for(i=0; i<6; i++) { if(v[i][c]!=mal[i]) mal2[i]=1; } for(i=0; i<64; i++) { igu=1; for(j=0; j<6; j++) { if(v[j][i]!=mal2[j]) { igu=0; break; } } if(igu) { flip.push_back(i); break; } } } else { flip.push_back(63); } return flip; } int find_coin(std::vector<int> b) { bool v[7][64],un,x,mal[7],igu=0,mal2[7]; memset(v,0,sizeof(v)); memset(mal,0,sizeof(mal)); memset(mal2,0,sizeof(mal2)); int i, j,ca,pos=0, bitMal=-1; for(i=1; i<64; i*=2) { ca=0; un=1; x=0; for(j=i; j<=64; j++) { if(ca==i) { un=!un; ca=0; } v[pos][j-1]=un; if(un) x^=b[j-1]; //cout << b[j-1] << ' '; ca++; } //cout << "fin "; mal[pos]=x; //cout << x << endl; pos++; } for(i=0; i<64; i++) { igu=1; for(j=0; j<6; j++) { if(v[j][i]!=mal[j]) { igu=0; break; } } if(igu) { bitMal=i; break; } } //cout << bitMal << endl; if(bitMal==-1) return 63; else return bitMal; }
#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...