# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
643142 | 2022-09-21T09:43:07 Z | TimDee | Password (RMI18_password) | C++17 | 5 ms | 268 KB |
#include <bits/stdc++.h> using namespace std; int query(string s); string guess(int n, int c) { if (c==2) { string A(n,'a'), B(n,'b'); int a=query(A),b=query(B); string ans; int added=0; for (int i=a; i>=0; --i) { string s; for (int j=0; j<i; ++j) s+='a'; for (int j=i; j<n; ++j) s+='b'; int x=query(s); for (int j=0; j<x-added-i; ++j) ans+='b'; ans+='a'; added=x-i; } ans.pop_back(); reverse(ans.begin(), ans.end()); return ans; } if (c==3) { string A(n,'a'), B(n,'b'), C(n,'c'); int a=query(A),b=query(B),c=query(C); string ans; int addedb=0,addedc=0; for (int i=a; i>=0; --i) { string s; for (int j=0; j<i; ++j) s+='a'; for (int j=i; j<n; ++j) s+='b'; int x=query(s)-i-addedb; s.clear(); for (int j=0; j<i; ++j) s+='a'; for (int j=i; j<n; ++j) s+='c'; int y=query(s)-i-addedc; string tmp(i,'a'); int added=0; if (y) { for (int j=x; j>=0; --j) { string s=tmp; for (int k=0; k<j; ++k) s+='b'; for (int k=0; k<y; ++k) s+='c'; int v=query(s)-i-j-added; for (int k=0; k<v; ++k) { ans+='c'; addedc++; added++; } ans+='b'; addedb++; } if (ans.size()) {ans.pop_back(); --addedb;} } else for(int k=0; k<x; ++k) {ans+='b'; addedb++;} ans.push_back('a'); } if (ans.size()) ans.pop_back(); reverse(ans.begin(), ans.end()); return ans; } if (c==4) { string A(n,'a'), B(n,'b'), C(n,'c'), D(n,'d'); int a=query(A),b=query(B),c=query(C),d=query(D); string ans; int addedb=0,addedc=0,addedd=0; for (int i=a; i>=0; --i) { string s; for (int j=0; j<i; ++j) s+='a'; for (int j=i; j<n; ++j) s+='b'; int x=query(s)-i-addedb; s.clear(); for (int j=0; j<i; ++j) s+='a'; for (int j=i; j<n; ++j) s+='c'; int y=query(s)-i-addedc; s.clear(); for (int j=0; j<i; ++j) s+='a'; for (int j=i; j<n; ++j) s+='d'; int z=query(s)-i-addedd; string tmp(i,'a'); //cout<<"! "<<x<<' '<<y<<' '<<z<<'\n'; int addedcnow=0, addeddnow=0; for (int j=x; j>=0; --j) { //cout<<": "<<ans<<'\n'; string tmp2(j,'b'); string s=tmp+tmp2; for (int k=0; k<y; ++k) s+='c'; int p=s.size()?(query(s)-i-j-addedcnow):0; s=tmp+tmp2; for (int k=0; k<z; ++k) s+='d'; int q=s.size()?(query(s)-i-j-addeddnow):0; //cout<<"~ "<<p<<' '<<q<<'\n'; int added=0; for (int k=p; k>=0; --k) { string s=tmp+tmp2; for (int l=0; l<k; ++l) s+='c'; for (int l=0; l<q; ++l) s+='d'; int v=s.size()?(query(s)-i-j-k-added):0; for (int l=0; l<v; ++l) { ++addedd; ans+='d'; ++added; ++addeddnow; } ans+='c'; ++addedc; ++addedcnow; } ans.pop_back(); --addedc; --addedcnow; ans+='b'; ++addedb; } ans.pop_back(); --addedb; ans.push_back('a'); } if (ans.size()) ans.pop_back(); reverse(ans.begin(), ans.end()); return ans; } if (n<=c && c<=26) { string ans(n,'.'); for (char i='a'; i<'a'+c; ++i) { int x=0; for (char j='a'; j<'a'+c; ++j) { if (j==i) continue; string s; s+=i; s+=j; int q=query(s); x+=q-1; } if (x<0) continue; ans[n-1-x]=i; } int paiu=1; for (auto x:ans) paiu&=x!='.'; if (paiu) return ans; } return "abc"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 208 KB | Guessed the password with 211 queries. |
2 | Correct | 5 ms | 208 KB | Guessed the password with 507 queries. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Guessed the password with 28 queries. |
2 | Correct | 2 ms | 268 KB | Guessed the password with 114 queries. |
3 | Correct | 0 ms | 208 KB | Guessed the password with 27 queries. |
4 | Incorrect | 2 ms | 208 KB | Returned early from guess() after 207 queries. |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | Returned early from guess() after 1 queries. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 208 KB | Guessed the password with 211 queries. |
2 | Correct | 5 ms | 208 KB | Guessed the password with 507 queries. |
3 | Correct | 1 ms | 208 KB | Guessed the password with 28 queries. |
4 | Correct | 2 ms | 268 KB | Guessed the password with 114 queries. |
5 | Correct | 0 ms | 208 KB | Guessed the password with 27 queries. |
6 | Incorrect | 2 ms | 208 KB | Returned early from guess() after 207 queries. |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 208 KB | Guessed the password with 211 queries. |
2 | Correct | 5 ms | 208 KB | Guessed the password with 507 queries. |
3 | Correct | 1 ms | 208 KB | Guessed the password with 28 queries. |
4 | Correct | 2 ms | 268 KB | Guessed the password with 114 queries. |
5 | Correct | 0 ms | 208 KB | Guessed the password with 27 queries. |
6 | Incorrect | 2 ms | 208 KB | Returned early from guess() after 207 queries. |
7 | Halted | 0 ms | 0 KB | - |