제출 #1238172

#제출 시각아이디문제언어결과실행 시간메모리
1238172em4ma2Coins (IOI17_coins)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "coins.h"
 
using namespace std;

#define pb push_back
#define ll long long

vector<int> coin_flips(vector<int>a,int c){
    vector<int>f;
    int x;
    for (int i=0;i<64;i++){
        if (a[i])x^=i;
    }
    int tmp=x^c;
    f.pb(tmp);
    // vector<int>tmp;
    // int cnt=0;
    // unordered_map<int,int>mp;
    // while(c){
    //     if (c%2){
    //         tmp.pb(cnt);
    //         mp[cnt]=1;
    //     }
    //     cnt++;
    //     c/=2;
    // }
    // for (auto x:tmp){
    //     if (a[x]!=1)f.pb(x);
    // }
    // for (int i=0;i<8;i++){
    //     if (a[i]==1 && !mp[i]){
    //         f.pb(i);
    //     }
    // }
    // if (f.size()==0){
    //     f.pb(1);
    //     f.pb(1);
    // }
    //cout<<f.size()<<endl;
    return f;
}

int find_coin(vector<int>a){
    int ans=0;
    for (int i=0;i<64;i++){
        if (a[i]){
            ans^=i;
        }
    }
    return ans;
}

static string run_test() {
	int c;
	cin >> c;
	vector<int> b(64);
	for (int i = 0; i < 8; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < 8; j++) {
			b[i * 8 + j] = int(s[j] - '0');
		}
	}
	vector<int> flips = coin_flips(b, c);
	if ((int)flips.size() == 0) {
		return "0 turn overs";
	}
	for (int i = 0; i < (int)flips.size(); i++) {
		if (flips[i] < 0 || flips[i] > 63) {
			return "cell number out of range";
		}
		b[flips[i]] = 1 - b[flips[i]];
	}
	int coin = find_coin(b);
	if (coin != c) {
		return "wrong coin";
	}
	return "ok";
}

int main() {
	int tests;
	cin >> tests;
	for (int t = 1; t <= tests; t++) {
		string result = run_test();
		cout << "test #" << t << ": " << result << endl;
	}
	return 0;
}

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

/usr/bin/ld: /tmp/cc97nkMW.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccs49MTo.o:coins.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status