This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "coins.h"
#include<bits/stdc++.h>
using namespace std;
std::vector<int> coin_flips(std::vector<int> b, int c) {
int bitsom[8];
memset(bitsom, 0, sizeof(bitsom));
std::vector<int> flips(1);
int cnt = 0;
for(int i = 0; i < 64; i++){
if(!b[i]) continue;
for(int j = 5; j >= 0; j--){
if(i&(1<<j))bitsom[j]++;
}
}
for(int i = 0; i < 6; i++){
// printf("%d\n", bitsom[i]);
bitsom[i]%=2;
}
int cur = 0;
for(int i = 0; i < 6; i++){
if(!bitsom[i]) continue;
cur |= 1<<i;
}
// printf("%d\n",cur );
flips[0] = cur^c;
return flips;
}
int find_coin(std::vector<int> b) {
int bitsom[8];
memset(bitsom, 0, sizeof(bitsom));
for(int i = 0; i < 64; i++){
// /printf("%d", b[i]);
// if(i%8 == 7)printf("\n");
if(!b[i]) continue;
for(int j = 5; j >= 0; j--){
if(i&(1<<j))bitsom[j]++;
}
}
for(int i = 0; i < 6; i++){
// printf("%d\n",bitsom[i] );
bitsom[i]%=2;
}
int cur = 0;
for(int i = 0; i < 6; i++){
if(!bitsom[i]) continue;
cur |= 1<<i;
}
return cur;
}
// vector<int> b;
// int main(){
// int atual = 0;
// int c;
// scanf("%d", &c);
// for(int i = 0; i < 64; i++){
// char q;
// scanf(" %c", &q);
// b.push_back(q - '0');
// }
// int mov = coin_flips(b,c)[0];
// b[mov] = 1-b[mov];
// printf("%d\n",find_coin(b) );
// }
Compilation message (stderr)
coins.cpp: In function 'std::vector<int> coin_flips(std::vector<int>, int)':
coins.cpp:9:9: warning: unused variable 'cnt' [-Wunused-variable]
9 | int cnt = 0;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |