제출 #1236554

#제출 시각아이디문제언어결과실행 시간메모리
1236554em4ma2콤보 (IOI18_combo)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> //#include "combo.h" using namespace std; #define pb push_back #define ll long long const int off=1<<19; const int inf=1e9+4; const int mxsz=2e5+4; int q(int x,int y){ cout<<"? "<<x<<" "<<y<<endl<<flush; int xx; cin>>xx; return xx; } void ans(char c){ cout<<"! "<<c<<endl<<flush; } int N=20; std::string S="ABYBXYBXYYBXYYYBXXYB"; constexpr int MAX_N = 2000; constexpr int MAX_NUM_MOVES = 8000; int num_moves; void wrong_answer(const char *MSG) { printf("Wrong Answer: %s\n", MSG); exit(0); } int press(std::string p) { if (++num_moves > MAX_NUM_MOVES) { wrong_answer("too many moves"); } int len = p.length(); if (len > 4 * N) { wrong_answer("invalid press"); } for (int i = 0; i < len; ++i) { if (p[i] != 'A' && p[i] != 'B' && p[i] != 'X' && p[i] != 'Y') { wrong_answer("invalid press"); } } int coins = 0; for (int i = 0, j = 0; i < len; ++i) { if (j < N && S[j] == p[i]) { ++j; } else if (S[0] == p[i]) { j = 1; } else { j = 0; } coins = std::max(coins, j); } return coins; } string guess_sequence(int n) { string p = "XY"; int x; //cout<<p<<endl; x=press(p); if (x>0){ p="X"; x=press(p); if (x==0){ p="Y"; } }else{ p="A"; x=press(p); if (x==0){ p="B"; } } string chs="ABXY"; for (int i=0;i<4;i++){ if (chs[i]==p[0])chs[i]='#'; } string k; for (auto x:chs){ if (x!='#')k.pb(x); } //cout<<k<<endl; int cnt=1; int tmp=n-2; int j=0; while (tmp--){ string s=p+k[j] +p+k[j+1]+k[j] +p+k[j+1]+k[j+1] +p+k[j+1]+k[j+2]; //cout<<"DSfj"; x=press(s); //cout<<"DSfj"; if (x==p.size()+0){ p+=k[j+2]; }else if (x==p.size()+1){ p+=k[j]; }else{ p+=k[j+1]; } cnt++; } string s=p+k[j] +p+k[j+1]; x=press(s); if (x==p.size()+1){ s=p+k[j]; x=press(s); if (x==cnt){ s=p+k[j+1]; } }else{ s=p+k[j+2]; } return s; } int main(){ int n; cin>>n; cout<<guess_sequence(n)<<endl; return 0; }

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

/usr/bin/ld: /tmp/ccm3bLEd.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/ccswo7fr.o:combo.cpp:(.text+0x230): first defined here
/usr/bin/ld: /tmp/ccm3bLEd.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccswo7fr.o:combo.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status