Submission #229937

#TimeUsernameProblemLanguageResultExecution timeMemory
229937kartelCombo (IOI18_combo)C++14
30 / 100
41 ms420 KiB
#include <bits/stdc++.h> //#include "grader.cpp" #include "combo.h" //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define in(x) freopen(x, "r", stdin) #define out(x) freopen(x, "w", stdout) #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-O3") #define F first #define S second #define pb push_back #define N +100500 #define M ll(1e9 + 7) #define sz(x) (int)x.size() #define re return #define oo ll(1e18) #define el '\n' using namespace std; //using namespace __gnu_pbds; //typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef long long ll; typedef long double ld; string guess_sequence(int n) { string s = ""; int len; int I, x, X, i, k, p, j, L, l, mk[2][5] {0}; srand(time(0)); char c[4] = {'A', 'B', 'X', 'Y'}; // random_shuffle(c, c + 4); for (i = 0; i < 4; i++) { s = ""; s += c[i]; p = press(s); if (p == 1) break; } I = i; len = 2; x = 0; while (len <= n) { x ^= 1; for (i = 0; i < 4; i++) mk[x][i] = 0; j = rand() % 3 + 1; l = 0; while (l < 4 && j > 0) { if (l == I) {l++;continue;} if (!mk[x][l]) j--; if (j == 0) break; l++; } // for (i = 0; i < 4; i++) cerr << mk[x][i] << " "; // cerr << el; // cerr << len << " " << c[l] << " " << s << el; s += c[l]; p = press(s); if (p == s.size()) {len++;continue;} if (p == sz(s) - 2) { int y = x ^ 1; i = 0; while (i < 4) { if (i == I) {i++;continue;} if (!mk[y][i]) break; i++; } s[sz(s) - 2] = c[i]; p = press(s); if (p == sz(s)) {len++;continue;} if (p < sz(s) - 1) assert(0 > 1); } s.erase(sz(s) - 1); mk[x][l] = 1; j = rand() % 2 + 1; l = 0; while (l < 4 && j > 0) { if (I == l) {l++;continue;} if (!mk[x][l]) j--; if (j == 0) break; l++; } s += c[l]; mk[x][l] = 1; len++; } if (len > 1) { p = press(s); if (p != sz(s)) { int y = x; i = 0; while (i < 4) { if (i == I) {i++;continue;} if (!mk[y][i]) break; i++; } s[sz(s) - 1] = c[i]; } } return s; } //int main() //{ // srand(time(0)); // ios_base::sync_with_stdio(0); // iostream::sync_with_stdio(0); // ios::sync_with_stdio(0); // cin.tie(NULL); // cout.tie(NULL); // //// in("input.txt"); //// out("output.txt"); // // //}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:70:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |             if (p == s.size()) {len++;continue;}
      |                 ~~^~~~~~~~~~~
combo.cpp:30:19: warning: unused variable 'X' [-Wunused-variable]
   30 |         int I, x, X, i, k, p, j, L, l, mk[2][5] {0};
      |                   ^
combo.cpp:30:25: warning: unused variable 'k' [-Wunused-variable]
   30 |         int I, x, X, i, k, p, j, L, l, mk[2][5] {0};
      |                         ^
combo.cpp:30:34: warning: unused variable 'L' [-Wunused-variable]
   30 |         int I, x, X, i, k, p, j, L, l, mk[2][5] {0};
      |                                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...