QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#674402 | #7531. Hacking the Project | ucup-team3161# | WA | 153ms | 11772kb | C++17 | 1.3kb | 2024-10-25 15:35:16 | 2024-10-25 15:35:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
const int N=1e3+5,INF=1e9;
int T,n,f[N][N],o[N][N];
vector<string> z,ans;
void init(int n)
{
for(int i=1;i<=n;++i) for(int j=i;j>=0;--j)
{
f[i][j]=INF;if(i==j) f[i][j]=0;
for(int k=j+1,t;k<=i;++k)
{
t=max(f[i-max(j,1)][0],f[i][k])+k;
if(t<f[i][j]) f[i][j]=t,o[i][j]=k;
}
}
}
void qry(char x,int y)
{
cout<<"query "<<x<<' '<<y<<endl;
int t;
cin>>t;
z.resize(t);
for(auto &a:z) cin>>a;
}
void slv()
{
cin>>n;
for(int i=0,t;i<26 && n;++i)
{
t=1;
qry('a'+i,1);
if(z.empty()) continue;
if(t==n)
{
for(auto a:z) ans.eb(a);
break;
}
while(1)
{
t=o[n][t];
qry('a'+i,t);
if(t==n || z.size()<t)
{
n-=z.size();
for(auto a:z) ans.eb(a);
break;
}
}
}
sort(ans.begin(),ans.end());
cout<<"answer ";
for(auto a:ans) cout<<a<<' ';
cout<<endl;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
init(1e3);
cin>>T;
while(T--) slv();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 153ms
memory: 11376kb
input:
1 4 1 aaa 2 aaa aba 2 aaa aba 0 1 cxyxy 2 cxyxy czzzz
output:
query a 1 query a 2 query a 4 query b 1 query c 1 query c 2 answer aaa aba cxyxy czzzz
result:
ok Ok in 11 k
Test #2:
score: -100
Wrong Answer
time: 147ms
memory: 11772kb
input:
5 1000 1 a 2 a aajm 6 a aajm aavfegkci aavj abjc abnxwsy 15 a aajm aavfegkci aavj abjc abnxwsy abzbr acvd adrvb af afbxpytbe afl afwsjfu aigwxskrks aimpdesf 33 a aajm aavfegkci aavj abjc abnxwsy abzbr acvd adrvb af afbxpytbe afl afwsjfu aigwxskrks aimpdesf ajbq alsqmc alswxsm anmkcljvyy anwwyoosx ao...
output:
query a 1 query a 2 query a 6 query a 15 query a 33 query a 69 query b 1 query b 2 query b 6 query b 15 query b 33 query b 69 query c 1 query c 2 query c 6 query c 15 query c 33 query c 69 query d 1 query d 3 query d 8 query d 19 query d 41 query d 83 query e 1 query e 2 query e 6 query e 14 query e...
result:
wrong answer Answer is wrong