Submission #316809

#TimeUsernameProblemLanguageResultExecution timeMemory
316809seedkinCombo (IOI18_combo)C++11
100 / 100
43 ms624 KiB
#include "combo.h" std::string guess_sequence(int N) { char map[200][3]; map['A'][0] = 'B'; map['A'][1] = 'X'; map['A'][2] = 'Y'; map['X'][0] = 'A'; map['X'][1] = 'B'; map['X'][2] = 'Y'; map['B'][0] = 'A'; map['B'][1] = 'X'; map['B'][2] = 'Y'; map['Y'][0] = 'A'; map['Y'][1] = 'X'; map['Y'][2] = 'B'; std::string p = ""; int coins; std::string S = ""; char first; if(N == 1) { p = 'A'; coins = press(p); if(coins) return p; p = 'B'; coins = press(p); if(coins) return p; p = 'X'; coins = press(p); if(coins) return p; p = 'Y'; return p; } else if (N == 2) { p = "AB"; coins = press(p); if(coins == 2) { S = "AB"; return S; } else if (coins == 1) { p = "A"; coins = press(p); if(coins) { S="A"; first = 'A'; } else { S="B"; first = 'B'; } } else { p = "X"; coins = press(p); if(coins) { S="X"; first = 'X'; } else { S="Y"; first = 'Y'; } } p = S + 'A' + S + 'B'; coins = press(p); if(coins == 2) { p = S +'A'; coins = press(p); if(coins == 2) { S += 'A'; } else { S += 'B'; } } else if (coins == 1) { p = S+'X'; coins = press(p); if(coins == 2) { S += 'X'; } else { S += 'Y'; } } return S; } else { p = "AB"; coins = press(p); if (coins >= 1) { p = "A"; coins = press(p); if(coins) { S="A"; first = 'A'; } else { S="B"; first = 'B'; } } else { p = "X"; coins = press(p); if(coins) { S="X"; first = 'X'; } else { S="Y"; first = 'Y'; } } int len = 1; // printf("first: %c\n",first); for(; len < N-1; len++) { p = S + map[first][0]; p += S + map[first][1] + map[first][0]; p += S + map[first][1] + map[first][1]; p += S + map[first][1] + map[first][2]; coins = press(p); if(coins == len) { S += map[first][2]; } else if (coins == len+1) { S += map[first][0]; } else { S += map[first][1]; } } p = S + 'A' + S + 'B'; coins = press(p); if(coins == N) { p = S +'A'; coins = press(p); if(coins == N) { S += 'A'; } else { S += 'B'; } } else if (coins == N-1) { p = S+'X'; coins = press(p); if(coins == N) { S += 'X'; } else { S += 'Y'; } } return S; } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:119:19: warning: array subscript has type 'char' [-Wchar-subscripts]
  119 |       p = S + map[first][0];
      |                   ^~~~~
combo.cpp:120:20: warning: array subscript has type 'char' [-Wchar-subscripts]
  120 |       p += S + map[first][1] + map[first][0];
      |                    ^~~~~
combo.cpp:120:36: warning: array subscript has type 'char' [-Wchar-subscripts]
  120 |       p += S + map[first][1] + map[first][0];
      |                                    ^~~~~
combo.cpp:121:20: warning: array subscript has type 'char' [-Wchar-subscripts]
  121 |       p += S + map[first][1] + map[first][1];
      |                    ^~~~~
combo.cpp:121:36: warning: array subscript has type 'char' [-Wchar-subscripts]
  121 |       p += S + map[first][1] + map[first][1];
      |                                    ^~~~~
combo.cpp:122:20: warning: array subscript has type 'char' [-Wchar-subscripts]
  122 |       p += S + map[first][1] + map[first][2];
      |                    ^~~~~
combo.cpp:122:36: warning: array subscript has type 'char' [-Wchar-subscripts]
  122 |       p += S + map[first][1] + map[first][2];
      |                                    ^~~~~
combo.cpp:127:18: warning: array subscript has type 'char' [-Wchar-subscripts]
  127 |         S += map[first][2];
      |                  ^~~~~
combo.cpp:129:18: warning: array subscript has type 'char' [-Wchar-subscripts]
  129 |         S += map[first][0];
      |                  ^~~~~
combo.cpp:131:18: warning: array subscript has type 'char' [-Wchar-subscripts]
  131 |         S += map[first][1];
      |                  ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...