제출 #433598

#제출 시각아이디문제언어결과실행 시간메모리
433598Amylopectin콤보 (IOI18_combo)C++14
100 / 100
85 ms668 KiB
#include <iostream> #include <stdio.h> #include <string> #include "combo.h" //#include "grader.cpp" using namespace std; char ds[4]; string guess_sequence(int n) { int i,j,cva,ru,k; string p = "",ans = ""; p = "AB"; cva = press(p); if(cva >= 1) { p = "A"; cva = press(p); if(cva == 1) { ds[0] = 'B'; ds[1] = 'X'; ds[2] = 'Y'; // ds = "BXY"; ans = "A"; } else { ds[0] = 'A'; ds[1] = 'X'; ds[2] = 'Y'; // ds = "AXY"; ans = "B"; } } else { p = "X"; cva = press(p); if(cva == 1) { ds[0] = 'A'; ds[1] = 'B'; ds[2] = 'Y'; // ds = "ABY"; ans = "X"; } else { ds[0] = 'A'; ds[1] = 'B'; ds[2] = 'X'; // ds = "ABX"; ans = "Y"; } } if(n == 1) { return ans; } for(i=1; i<n-1; i++) { ru = 0; p = ""; for(j=0; j<i; j++) { // p[ru] = ans[j]; // ru ++; p.push_back(ans[j]); } p.push_back(ds[0]); // p[ru] = ds[0]; // ru ++; for(j=0; j<3; j++) { for(k=0; k<i; k++) { p.push_back(ans[k]); // p[ru] = ans[k]; // ru ++; } p.push_back(ds[1]); p.push_back(ds[j]); // p[ru] = ds[1]; // ru ++; // p[ru] = ds[j]; // ru ++; } cva = press(p); if(cva == i) { ans.push_back(ds[2]); // ans[i] = ds[2]; } else if(cva == i+1) { ans.push_back(ds[0]); // ans[i] = ds[0]; } else { ans.push_back(ds[1]); // ans[i] = ds[1]; } } p = ans; p.push_back(ds[0]); cva = press(p); if(cva == n) { ans.push_back(ds[0]); } else { p = ans; p.push_back(ds[1]); cva = press(p); if(cva == n) { ans.push_back(ds[1]); } else { ans.push_back(ds[2]); } } // for (int i = 0; i < 4 * n; ++i) // { // p += 'A'; // } // int coins = press(p); // string S = ""; // for (int i = 0; i < n; ++i) // { // S += 'A'; // } return ans; } //int main() //{ // cout << "Hello world!" << endl; // return 0; //}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:10:17: warning: variable 'ru' set but not used [-Wunused-but-set-variable]
   10 |     int i,j,cva,ru,k;
      |                 ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...