Submission #1296951

#TimeUsernameProblemLanguageResultExecution timeMemory
1296951basaPassword (RMI18_password)C++20
0 / 100
3081 ms492864 KiB
#include "bits/stdc++.h" using namespace std; int query(string s); string guess(int n, int s){ array<int, 2>shi[30][30]; for(int i = 0; i < s; i++){ for(int j = i + 1; j < s; j++){ string a = "", b = ""; for(int k = 0; k < n; k++) a += (k % 2 ? j + 'a' : i + 'a'); for(int k = 0; k < n; k++) b += (k % 2 ? i + 'a' : j + 'a'); int ra = query(a), rb = query(b); if(ra > rb) shi[i][j] = {ra, i}; else shi[i][j] = {rb, j}; } } string sk = ""; bool valid = 1; int cnt[30][30] = {}; while(valid){ valid = 0; bool idk[30]; for(int i = 0; i < 30; i++) idk[i] = 1; for(int i = 0; i < s; i++){ for(int j = i + 1; j < s; j++){ if(cnt[i][j] >= shi[i][j][0]) continue; valid = 1; int f, se; if(shi[i][j][1] == i){ f = i; se = j; } else{ f = j; se = i; } if(cnt[i][j] % 2 == 0) idk[se] = 0; else idk[f] = 0; } } if(!valid) continue; for(int i = 0; i < s; i++){ if(idk[i]){ sk += i + 'a'; for(int j = i + 1; j < s; j++) cnt[i][j]++; for(int j = 0; j < i; j++) cnt[j][i]++; break; } } } if(s == 1) sk = 'a'; int cur = 0; string ans = ""; while(cur < sk.size()){ string fh = "", sh = ""; for(int i = 0; i < cur; i++) fh += sk[i]; for(int i = cur + 1; i < sk.size(); i++) sh += sk[i]; int idk = n; for(int i = 1; i <= n; i++){ string tmp = fh; for(int j = 0; j < i; j++) tmp += sk[cur]; tmp += sh; if(tmp.size() > n){ idk = i - 1; break; } int a = query(tmp); if(a != tmp.size()){ idk = i - 1; break; } } for(int i = 0; i < idk; i++) ans += sk[cur]; cur++; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...