Submission #1241234

#TimeUsernameProblemLanguageResultExecution timeMemory
1241234HanksburgerPassword (RMI18_password)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; string guess(int N, int S) { vector<pair<int, int> > vec; int freq[26]; for (int i=0; i<S; i++) { string tmp; for (int j=0; j<N; j++) tmp.push_back('a'+i); freq[i]=query(tmp); vec.push_back({freq[i], i}); } sort(vec.begin(), vec.end(), greater<pair<int, int> >()); string cur; for (int j=0; j<vec[0].first; j++) cur.push_back('a'+vec[0].second); for (int i=1; i<vec.size(); i++) { for (int j=1; j<=vec[i].first; j++) { string tmp; for (int k=0; k<j; k++) tmp.push_back('a'+vec[i].second); for (int k=j; k<N; k++) tmp.push_back('a'+vec[0].second); int res=vec[0].first-(query(tmp)-j), cnt=0, l=-1, r; for (int k=0; k<=cur.length(); k++) { if (l==-1 && cnt==res) l=k; if (k==cur.length() || cur[k]=='a'+vec[0].second) cnt++; if (cnt==res+1) { r=k; break; } } while (l<r) { int mid=(l+r)/2; tmp.clear(); for (int k=0; k<j; k++) tmp.push_back('a'+vec[i].second); for (int k=j; k<N; k++) tmp.push_back(cur[mid]); res=freq[cur[mid]-'a']-(query(tmp)-j), cnt=0; for (int k=0; k<=mid; k++) if (cur[k]==cur[mid]) cnt++; if (res>=cnt) l=mid+1; else r=mid; } cur.insert(cur.begin()+l, 'a'+vec[i].second); } } return cur; }

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:12:17: error: 'query' was not declared in this scope
   12 |         freq[i]=query(tmp);
      |                 ^~~~~
password.cpp:28:35: error: 'query' was not declared in this scope
   28 |             int res=vec[0].first-(query(tmp)-j), cnt=0, l=-1, r;
      |                                   ^~~~~
password.cpp:31:21: error: 'l' was not declared in this scope
   31 |                 if (l==-1 && cnt==res)
      |                     ^
password.cpp:31:30: error: 'cnt' was not declared in this scope; did you mean 'int'?
   31 |                 if (l==-1 && cnt==res)
      |                              ^~~
      |                              int
password.cpp:34:21: error: 'cnt' was not declared in this scope; did you mean 'int'?
   34 |                     cnt++;
      |                     ^~~
      |                     int
password.cpp:35:21: error: 'cnt' was not declared in this scope; did you mean 'int'?
   35 |                 if (cnt==res+1)
      |                     ^~~
      |                     int
password.cpp:37:21: error: 'r' was not declared in this scope
   37 |                     r=k;
      |                     ^
password.cpp:41:22: error: 'r' was not declared in this scope
   41 |             while (l<r)
      |                      ^
password.cpp:41:20: error: 'l' was not declared in this scope
   41 |             while (l<r)
      |                    ^
password.cpp:49:56: error: 'cnt' was not declared in this scope; did you mean 'int'?
   49 |                 res=freq[cur[mid]-'a']-(query(tmp)-j), cnt=0;
      |                                                        ^~~
      |                                                        int
password.cpp:58:36: error: 'l' was not declared in this scope
   58 |             cur.insert(cur.begin()+l, 'a'+vec[i].second);
      |                                    ^