Submission #557442

#TimeUsernameProblemLanguageResultExecution timeMemory
557442FatihSolakPassword (RMI18_password)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int query(string str); string password; int query(string q) { int len = q.size(); int i = 0, j = 0, plen = password.size(); while (i < plen && j < len) { while ((i < plen) && (password[i] != q[j])) { i++; } if (i < plen) { i++; j++; } } return j; } int rem[30][30][5005]; int tot = 50000; int myquery(string &s){ assert(tot--); return query(s); } int ask(int a,int b,int c,int d){ if(rem[a][b][c] != -1)return rem[a][b][c]; string tmp = ""; for(int i = 0;i<c;i++) tmp += a + 'a'; for(int i = 0;i<d;i++) tmp += b + 'a'; return rem[a][b][c] = myquery(tmp); } mt19937 rng(31); string guess(int n, int s){ for(int i = 0;i<30;i++){ for(int j = 0;j<30;j++){ for(int c = 0;c<5005;c++){ rem[i][j][c] = -1; } } } vector<int> v; for(int i = 0;i<s;i++){ v.push_back(i); } //shuffle(v.begin(),v.end(),rng); vector<int> cnt(s); vector<int> used(s); vector<int> init(s); for(int i = 0;i<s;i++){ cnt[v[i]] = ask(v[i],0,n,0); init[v[i]] = cnt[v[i]]; } string res = ""; for(int x = n-1;x>=0;x--){ int val = 0; while(cnt[v[val]] == 0) val++; for(int i = val+1;i<s;i++){ if(cnt[v[i]] == 0)continue; if(ask(v[val],v[i],cnt[v[val]],init[v[i]]) >= cnt[v[val]] + used[v[i]] + 1){ val = i; } } res += v[val] + 'a'; used[v[val]]++; cnt[v[val]]--; vector<int> tmp; for(int i = 0;i<val;i++){ tmp.push_back(v[i]); } for(int i = val+1;i<v.size();i++){ tmp.push_back(v[i]); } tmp.push_back(v[val]); v = tmp; //cout << res << endl; } reverse(res.begin(),res.end()); return res; } int main(){ #ifdef Local freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int n,s; cin >> n >> s; cin >> password; guess(n,s); }

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:73:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |         for(int i = val+1;i<v.size();i++){
      |                           ~^~~~~~~~~
/usr/bin/ld: /tmp/ccCwWLer.o: in function `query(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x80): multiple definition of `query(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/cc5i7pEn.o:password.cpp:(.text+0xc0): first defined here
/usr/bin/ld: /tmp/ccCwWLer.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc5i7pEn.o:password.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status