제출 #648058

#제출 시각아이디문제언어결과실행 시간메모리
648058ojoConmigoCoins (IOI17_coins)C++17
0 / 100
2 ms976 KiB
#include "coins.h"

//#include <bits/stdc++.h>
//using namespace std;

std::vector<int> coin_flips(std::vector<int> b, int c) {
    /* Subtask 1 y 2
    std::vector<int> flips(1);
    flips[0] = 63;
    if(b[0] == b[1] && b[1] == b[2]){
        flips[0] = c;
    }else{
        for(int i=0; i<3; i++){
            if(c == i)continue;
            if(b[i] == b[c]){
                flips[0] = i;
            }
        }
    }
    */
    std::vector<int> flips;
    for(int i=0; i<6; i++){
        if(c & (1<<i) != b[i]){
            flips.push_back(i);
        }
    }
    return flips; 
}

int find_coin(std::vector<int> b) {
    /* Subtask 1 y 2
    if (b[0] == b[1]) {
        return 2;
    }else if(b[0] == b[2]){
        return 1;
    }else return 0;
    */
    int sol = 0;
    for(int i=0; i<6; i++){
        if(b[i]){
            sol += (1<<i);
        }
    }
    return sol;
}

/*
int main(){
    int t;
    cin >> t;
    while(t--){
        int c;
        cin >> c;
        vector<int> b(64);
        for(int i=0; i<64; i++){
            cin >> b[i];
        }
        vector<int> flips = coin_flips(b,c);
        for(int x : flips){
            b[x] = 1 - b[x];
        }
        for(int i=0; i<8; i++){
            for(int j=0; j<8; j++){
                cout << b[i*8+j];
            }
            cout << endl;
        }
        cout << find_coin(b) << endl;
    }
}
*/

컴파일 시 표준 에러 (stderr) 메시지

coins.cpp: In function 'std::vector<int> coin_flips(std::vector<int>, int)':
coins.cpp:23:23: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   23 |         if(c & (1<<i) != b[i]){
#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...