Submission #866634

#TimeUsernameProblemLanguageResultExecution timeMemory
866634sofija6Password (RMI18_password)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; string guess(int n, int s) { string ans=""; int cnt[26]={0}; for (int i=0;i<26;i++) { int l=1,r=n,mid; while (l<=r) { mid=(l+r)/2; string s=""; for (int j=1;j<=mid;j++) s+=(char)('a'+i); if (query(s)==mid) { cnt[i]=mid; l=mid+1; } else r=mid-1; } } for (int i=1;i<=n;i++) { int l=0,r=25,mid,lastt=-1; while (l<=r) { mid=(l+r)/2; string s=ans; for (int j=0;j<=mid;j++) { if (cnt[j]) s+=(char)(j+'a'); } if (query(s)>ans.size()) { lastt=mid; r=mid-1; } else l=mid+1; } ans+=(char)(lastt+'a'); cnt[lastt]--; } return ans; }

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:18:17: error: 'query' was not declared in this scope
   18 |             if (query(s)==mid)
      |                 ^~~~~
password.cpp:39:17: error: 'query' was not declared in this scope
   39 |             if (query(s)>ans.size())
      |                 ^~~~~