제출 #1238008

#제출 시각아이디문제언어결과실행 시간메모리
1238008em4ma2Coins (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;
    vector<int>tmp;
    int cnt=0;
    while(c){
        if (c%2)tmp.pb(cnt);
        cnt++;
        c/=2;
    }
    for (auto x:tmp){
        //cout<<x<<" ";
        if (a[x]!=1)f.pb(x);
    }
    for (int i=0;i<8;i++){
        if (a[i]==1 && !count(tmp.begin(),tmp.end(),i)){
            f.pb(i);
        }
    }
    // for (auto x:f){
    //     cout<<x<<" ";
    // }
    if (f.size()==0){
        f.pb(1);
        f.pb(1);
    }
    return f;
}

// int find_coin(vector<int>a){
//     // for (auto x:a){
//     //     cout<<x<<" ";
//     // }
//     int ans;
//     for (int i=0;i<8;i++){
//         ans+=(1<<i)*a[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/cc5RBwEN.o: in function `main':
grader.cpp:(.text.startup+0xb8a): undefined reference to `find_coin(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status