QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#769497 | #7510. Independent Set | maxyzfj | WA | 1ms | 4108kb | C++14 | 3.3kb | 2024-11-21 17:55:44 | 2024-11-21 17:55:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mp(x,y) make_pair(x,y)
#define lb(x) (x&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define piii pair<int,pair<int,int> >
int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=x*10+ch-48;
ch=getchar();
}
return x*f;
}
void writ(int x){
if(x<0){
putchar('-'),x=-x;
}
if(x>9){
writ(x/10);
}
putchar(x%10 +'0');
}
void write(int x,char p=' '){
writ(x);
putchar(p);
}
string sread(){
string t="";
char c=getchar();
while(c==' '||c=='\t'||c=='\r'||c=='\n'||c==0||c==EOF){
c=getchar();
}
while(!(c==' '||c=='\t'||c=='\r'||c=='\n'||c==0||c==EOF)){
t+=c,c=getchar();
}
return t;
}
const int QMR=1000000007,LSJ=998244353,inf=2e18+31,N=4005;
//int cal(int a,int b=QMR-2){
// int base=a,ret=1;
// while(b){
// if(b&1){
// ret=ret*base%QMR;
// }
// base=base*base%QMR;
// b>>=1;
// }
// return ret;
//}
mt19937 rnd(time(0)^clock());
int n,a[N];
map<basic_string<int>,basic_string<int> >h;
basic_string<int> query(basic_string<int>t){
if(t.size()==1){
t[0]=0;return t;
}
if(h.find(t)!=h.end())return h[t];
cout<<"? ";
write(t.size());
for(int i:t)write(i);
cout<<endl;
basic_string<int>g;
for(int i:t){
int qmr;cin>>qmr;g+=qmr;
}
return h[t]=g;
}
int cnt=0;
basic_string<int>ans[N],b[N],qmr;
void work(int k,int l,int r,basic_string<int>s){
if(l==r){
s=b[k][l]+s;
basic_string<int>lsj=query(s);
for(int i=1;i<lsj.size();i++){
if(lsj[i]-ans[s[i]].size()>0){
// cout<<lsj[i]<<" "<<s[i]<<" "<<ans[s[i]].size()<<endl;
int tt=lsj[i]-ans[s[i]].size();
for(int j=1;j<=tt;j++)ans[s[i]]+=b[k][l];
}
}
return;
}
int mid=(l+r)>>1;
basic_string<int>L,R,ll,rr;
for(int i=l;i<=mid;i++){
L+=b[k][i];
}
for(int i=mid+1;i<=r;i++){
R+=b[k][i];
}
basic_string<int>lsj=query(L+s);
for(int i=L.size();i<lsj.size();i++){
if(lsj[i]-ans[s[i-L.size()]].size()>0){
ll+=s[i-L.size()];
}
}
lsj=query(R+s);
for(int i=R.size();i<lsj.size();i++){
if(lsj[i]-ans[s[i-R.size()]].size()>0){
rr+=s[i-R.size()];
}
}
L.clear();R.clear();
work(k,l,mid,ll);
work(k,mid+1,r,rr);
}
signed main(){
//freopen("qmr.in","r",stdin);
//freopen("qmr.out","w",stdout);
n=read();
basic_string<int>g;
for(int i=1;i<=n;i++)g+=i;
while(g.size()){
cnt++;
basic_string<int>tt=query(g),c,d;
for(int i=0;i<tt.size();i++){
if(tt[i]!=0)c+=g[i];
else b[cnt]+=g[i];
}
g=c;
}
return 0;
basic_string<int>tmp=b[cnt];
qmr=query(b[cnt]+b[cnt]);
for(int j=b[cnt].size();j<2*b[cnt].size();j++){
a[b[cnt][j-b[cnt].size()]]=qmr[j];
}
for(int i=cnt-1;i>=1;i--){
qmr=query(b[i]+b[i]+tmp);
for(int j=b[i].size();j<2*b[i].size();j++){
a[b[i][j-b[i].size()]]=qmr[j];
}
work(i,0,b[i].size()-1,tmp);
tmp+=b[i];
}
int m=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=a[i];j++)ans[i]+=i;
m+=ans[i].size();
}
putchar('!');
putchar(32);
write(m);
for(int i=1;i<=n;i++){
for(int j:ans[i])write(i),write(j);
}
cout<<endl;
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4108kb
input:
4 0 2 1 0 0 0
output:
? 4 1 2 3 4 ? 2 2 3
result:
wrong answer format Unexpected end of file - token expected