Submission #99278

#TimeUsernameProblemLanguageResultExecution timeMemory
99278wleung_bvg콤보 (IOI18_combo)C++14
Compilation error
0 ms0 KiB
//============================================================================
// Name        : ioi18p1.cpp
// Author      : Daxi the Taxi
// Version     :
// Copyright   : ALL YOUR CODE IS BELONG TO US
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> p;

#ifndef ONLINE_JUDGE
int press(string s);
#endif

string guess_sequence(int n){
	string curr = "", usable = "";

	// Guessing first letter
	int ret = press("AB");
	if(ret){
		ret = press("A");
		if(ret)
			curr = "A", usable = "BXY";
		else
			curr = "B", usable = "AXY";
	}
	else{
		ret = press("X");
		if(ret)
			curr = "X", usable = "ABY";
		else
			curr = "Y", usable = "ABX";
	}

	// Rest of it
	for (int i = 1; i < n; ++i) {
		ret = press(curr + usable[0] + curr + usable[1]);
		if(ret > i){
			ret = press(curr + usable[0]);
			if(ret > i)
				curr += usable[0];
			else
				curr += usable[1];
		}
		else
			curr += usable[2];
	}

	return curr;
}

#ifndef ONLINE_JUDGE
const int N = 5;
const string STR = "ABXYY";

int press(string s){
	int sz = s.length(), ptr = 0, best = INT_MIN;
	for (int i = 0; i < sz; ++i) {
		if(s[i] == STR[ptr])
			ptr++;
		else
			ptr = 0;
		best = max(best, ptr);
	}
	return best;
}

int main(){
	printf("%s\n", guess_sequence(N).c_str());
	return 0;
}
#endif

Compilation message (stderr)

/usr/bin/ld: /tmp/ccxaWM1v.o: in function `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x0): multiple definition of `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/cc2oAJ0y.o:combo.cpp:(.text+0xc0): first defined here
/usr/bin/ld: /tmp/ccxaWM1v.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc2oAJ0y.o:combo.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status