QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#288098 | #7510. Independent Set | 1kri | Compile Error | / | / | C++14 | 1.7kb | 2023-12-21 20:51:05 | 2023-12-21 20:51:06 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
vector<int> ask(vector<int> a){
int l=(int)a.size();
cout<<"? "<<l<<' ';
for (int i=0;i<l;i++)cout<<a[i]<<' ';
cout<<endl;
vector<int> ans(l);
for (int i=0;i<l;i++)cin>>ans[i];
return ans;
}
int cnt[4005][4005];
vector<pair<int,int>> qwq[10005];
void work(int now,int l,int r){
if (l==r){
for (int i=0;i<(int)qwq[now].size();i++)
cnt[l][qwq[now][i].first]=qwq[now][i].second;
cnt[l][l]=ask({l})[0];
return;
}
int mid=(l+r)/2;
vector<int> ovo;
for (int i=l;i<=mid;i++)ovo.push_back(i);
for (int i=0;i<(int)qwq[now].size();i++)ovo.push_back(qwq[now][i].first);
vector<int> awa=ask(ovo);
sort(qwq[now].begin(),qwq[now].end());
for (int i=0;i<(int)qwq[now].size();i++){
int p=awa[mid-l+1+i];
for (int j=0;j<=i;j++)p-=cnt[qwq[now][j].first][qwq[now][i].first];
if (p>0)qwq[now*2].push_back(make_pair(qwq[now][i].first,p));
if (p<qwq[now][i].second)qwq[now*2+1].push_back(make_pair(qwq[now][i].first,qwq[now][i].second-p));
}
work(now*2+1,mid+1,r);
ovo.clear(),awa.clear();
for (int i=l;i<=r;i++)ovo.push_back(i);
awa=ask(ovo);
for (int i=0;i<r-mid;i++){
int p=awa[mid-l+1+i];
for (int j=0;j<=i;j++)p-=cnt[mid+1+j][mid+1+i];
if (p>0)qwq[now*2].push_back(make_pair(mid+1+i,p));
}
work(now*2,l,mid);
return;
}
int main(){
int n;
cin>>n;
work(1,1,n);
int m=0;
for (int i=1;i<=n;i++)
for (int j=i;j<=n;j++)
for (int k=1;k<=cnt[i][j];k++)
m++;
cout<<"! "<<m<<' ';
for (int i=1;i<=n;i++)
for (int j=i;j<=n;j++)
for (int k=1;k<=cnt[i][j];k++)
cout<<i<<' '<<j<<' ';
cout<<endl;
return 0;
}
詳細信息
answer.code:5:1: error: ‘vector’ does not name a type 5 | vector<int> ask(vector<int> a){ | ^~~~~~ answer.code:15:1: error: ‘vector’ does not name a type 15 | vector<pair<int,int>> qwq[10005]; | ^~~~~~ answer.code: In function ‘void work(int, int, int)’: answer.code:18:37: error: ‘qwq’ was not declared in this scope 18 | for (int i=0;i<(int)qwq[now].size();i++) | ^~~ answer.code:20:27: error: ‘ask’ was not declared in this scope 20 | cnt[l][l]=ask({l})[0]; | ^~~ answer.code:24:9: error: ‘vector’ was not declared in this scope 24 | vector<int> ovo; | ^~~~~~ answer.code:4:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’? 3 | #include <algorithm> +++ |+#include <vector> 4 | using namespace std; answer.code:24:16: error: expected primary-expression before ‘int’ 24 | vector<int> ovo; | ^~~ answer.code:25:33: error: ‘ovo’ was not declared in this scope 25 | for (int i=l;i<=mid;i++)ovo.push_back(i); | ^~~ answer.code:26:29: error: ‘qwq’ was not declared in this scope 26 | for (int i=0;i<(int)qwq[now].size();i++)ovo.push_back(qwq[now][i].first); | ^~~ answer.code:26:49: error: ‘ovo’ was not declared in this scope 26 | for (int i=0;i<(int)qwq[now].size();i++)ovo.push_back(qwq[now][i].first); | ^~~ answer.code:27:16: error: expected primary-expression before ‘int’ 27 | vector<int> awa=ask(ovo); | ^~~ answer.code:28:14: error: ‘qwq’ was not declared in this scope 28 | sort(qwq[now].begin(),qwq[now].end()); | ^~~ answer.code:30:23: error: ‘awa’ was not declared in this scope 30 | int p=awa[mid-l+1+i]; | ^~~ answer.code:36:9: error: ‘ovo’ was not declared in this scope 36 | ovo.clear(),awa.clear(); | ^~~ answer.code:36:21: error: ‘awa’ was not declared in this scope 36 | ovo.clear(),awa.clear(); | ^~~ answer.code:38:13: error: ‘ask’ was not declared in this scope 38 | awa=ask(ovo); | ^~~