QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#86989#4218. Hidden GraphAFewSunsCompile Error//C++143.0kb2023-03-11 15:52:002023-03-11 15:52:03

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-11 15:52:03]
  • 评测
  • [2023-03-11 15:52:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
#define fl fflush(stdout)
vector<ll> vec[2020],qry,e[2020];
vector<pair<ll,ll> > ans;
ll n,k=0,d[2020],dd[2020],id[2020],col[2020];
bl ck[2020],pd[2020];
struct node{
	ll id,d;
};
il bl operator<(const node &x,const node &y){
	return x.d>y.d;
}
void query(){
	pf("? %lld ",qry.size());
	fr(i,0,(ll)qry.size()-1) writesp(qry[i]);
	enter;
	fl;
}
il bl cmp(ll x,ll y){
	return d[x]<d[y];
}
priority_queue<node> q;
void solve(ll x){
	fr(i,1,x) id[i]=i;
	sort(id+1,id+x+1,cmp);
//	fr(i,1,x) dd[i]=d[i];
//	fr(i,1,x) q.push((node){i,dd[i]});
//	fr(i,1,x) ck[i]=0;
//	ll cnt=0;
//	while(!q.empty()){
//		node u=q.top();
//		q.pop();
//		if(ck[u.id]) continue;
//		ck[u.id]=1;
//		id[++cnt]=u.id;
//		fr(i,0,(ll)e[u.id].size()-1){
//			ll v=e[u.id][i];
//			if(!ck[v]){
//				dd[v]--;
//				q.push((node){v,dd[v]});
//			}
//		}
//	}
//	k=0;
	pfr(i,cnt,1){
		ll u=id[i];
		col[u]=0;
		fr(j,1,k) pd[j]=0;
		fr(j,0,(ll)e[u].size()-1) if(col[e[u][j]]) pd[col[e[u][j]]]=1;
		pfr(j,k,1) if(!pd[j]) col[u]=j;
		if(!col[u]) col[u]=++k;
	}
	fr(i,1,k) vec[i].clear();
	fr(i,1,x) vec[col[i]].push_back(i);
}
int main(){
	n=read();
	fr(i,1,n){
		fr(j,1,k){
			fr(l,0,(ll)vec[j].size()-1) ck[vec[j][l]]=0;
			while(1){
				qry.clear();
				fr(l,0,(ll)vec[j].size()-1) if(!ck[vec[j][l]]) qry.push_back(vec[j][l]);
				if(qry.empty()) break;
				qry.push_back(i);
				query();
				ll u=read(),v=read();
				if(u==-1) break;
				ck[u+v-i]=1;
				ans.push_back(MP(u,v));
				e[u].push_back(v);
				e[v].push_back(u);
				d[u]++;
				d[v]++;
			}
		}
		solve(i);
		if(n==2000) assert(k<=2);
	}
	pf("! %lld\n",(ll)ans.size());
	fr(i,0,(ll)ans.size()-1) pf("%lld %lld\n",ans[i].fir,ans[i].sec);
	fl;
}

详细

answer.code: In function ‘void query()’:
answer.code:84:18: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
   84 |         pf("? %lld ",qry.size());
      |               ~~~^   ~~~~~~~~~~
      |                  |           |
      |                  |           std::vector<long long int>::size_type {aka long unsigned int}
      |                  long long int
      |               %ld
answer.code: In function ‘void solve(long long int)’:
answer.code:115:15: error: ‘cnt’ was not declared in this scope; did you mean ‘int’?
  115 |         pfr(i,cnt,1){
      |               ^~~
answer.code:30:47: note: in definition of macro ‘pfr’
   30 |         #define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
      |                                               ^