Submission #316799

#TimeUsernameProblemLanguageResultExecution timeMemory
316799seedkinCombo (IOI18_combo)C++11
0 / 100
1 ms328 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 = "AAAB"; coins = press(p); if(coins == 4) { S = "AB"; return S; } else if (coins == 3) { S += 'A'; first = 'A'; } else if (coins == 1) { S += 'B'; first = 'B'; } p = "XXXY"; coins = press(p); if(coins == 4) { S = "XY"; return S; } else if (coins == 3) { S += 'X'; first = 'X'; } else if (coins == 1) { S += 'Y'; first = 'Y'; } p = S + map[first][0]; p += S + map[first][1]; p += S + map[first][1]; coins = press(p); if(coins == 3) { S += map[first][2]; } else if (coins == 4) { S += map[first][0]; } else { S += map[first][1]; } return S; } else { p = "AAAB"; coins = press(p); if (coins >= 3) { S += 'A'; first = 'A'; } else if (coins == 1) { S += 'B'; first = 'B'; } p = "XXXY"; coins = press(p); if (coins >= 3) { S += 'X'; first = 'X'; } else if (coins == 1) { S += 'Y'; first = 'Y'; } int len = 1; for(; len < N; len++) { p = S + map[first][0]; p += S + map[first][1]; p += S + map[first][1]; coins = press(p); if(coins == len * 3) { S += map[first][2]; } else if (coins == len * 3 + 1) { S += map[first][0]; } else { S += map[first][1]; } } } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:64:17: warning: array subscript has type 'char' [-Wchar-subscripts]
   64 |     p = S + map[first][0];
      |                 ^~~~~
combo.cpp:65:18: warning: array subscript has type 'char' [-Wchar-subscripts]
   65 |     p += S + map[first][1];
      |                  ^~~~~
combo.cpp:66:18: warning: array subscript has type 'char' [-Wchar-subscripts]
   66 |     p += S + map[first][1];
      |                  ^~~~~
combo.cpp:71:16: warning: array subscript has type 'char' [-Wchar-subscripts]
   71 |       S += map[first][2];
      |                ^~~~~
combo.cpp:73:16: warning: array subscript has type 'char' [-Wchar-subscripts]
   73 |       S += map[first][0];
      |                ^~~~~
combo.cpp:75:16: warning: array subscript has type 'char' [-Wchar-subscripts]
   75 |       S += map[first][1];
      |                ^~~~~
combo.cpp:102:19: warning: array subscript has type 'char' [-Wchar-subscripts]
  102 |       p = S + map[first][0];
      |                   ^~~~~
combo.cpp:103:20: warning: array subscript has type 'char' [-Wchar-subscripts]
  103 |       p += S + map[first][1];
      |                    ^~~~~
combo.cpp:104:20: warning: array subscript has type 'char' [-Wchar-subscripts]
  104 |       p += S + map[first][1];
      |                    ^~~~~
combo.cpp:109:18: warning: array subscript has type 'char' [-Wchar-subscripts]
  109 |         S += map[first][2];
      |                  ^~~~~
combo.cpp:111:18: warning: array subscript has type 'char' [-Wchar-subscripts]
  111 |         S += map[first][0];
      |                  ^~~~~
combo.cpp:113:18: warning: array subscript has type 'char' [-Wchar-subscripts]
  113 |         S += map[first][1];
      |                  ^~~~~
combo.cpp:102:19: warning: 'first' may be used uninitialized in this function [-Wmaybe-uninitialized]
  102 |       p = S + map[first][0];
      |                   ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...