Submission #1219119

#TimeUsernameProblemLanguageResultExecution timeMemory
1219119nataliaaCoins (IOI17_coins)C++20
Compilation error
0 ms0 KiB
//#include "coins.h"
#include<bits/stdc++.h>

using namespace std;
vector<int> coin_flips(vector<int> b, int c) {
   vector<int> v;
   int j = 6;
   while(j--) {
        v.push_back(c%2);
        c/=2;
   }
   vector<int> v1;
 reverse(v.begin(), v.end());
   for(int i =0; i < 6; i++) {
       if(b[i]!=v[i]) v1.push_back(i);
        b[i] = v[i];
   }
   
   return v1;

} 

int find_coin(vector<int> b) {
    int a[6] = {1, 2, 4, 8, 16 , 32};
    int c = 0;
    for(int i = 0; i < 6; i++) {
        if(b[i]==1) c+=a[6-i-1];
    }
    return c;
}
static string run_test() {
	int c;
	cin >> c;
	vector<int> b(64, 0);
	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;
}

Compilation message (stderr)

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