QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#450583#6874. Leshphonmzmz001Compile Error//C++142.3kb2024-06-22 15:55:252024-06-22 15:55:25

Judging History

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

  • [2024-06-22 15:55:25]
  • 评测
  • [2024-06-22 15:55:25]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll T,n,m,S;
ll G1[55],G2[55],vis,num1[55][55],num2[55][55],ans;
queue<ll> q,q1,q2,q3,Q1,Q2,q4,q5;
struct node{
	ll u,v,op;//0:spare 1:deleted 2:unsed 
}E[2505];
void bfs(ll GG[],ll num[][55],queue<ll> &Q){
	q.push(1ll);
	vis=1ll;
	while(!q.empty()){
		ll u=q.front();
		q.pop();
		ll G=GG[u];
		G^=(G&vis);
		vis|=G;
		for(;G;G^=G&-G){
			ll v=__builtin_ctzll(G)+1ll;
			q.push(v);
			Q.push(num[u][v]);
		}
	}
}
bool check(){
	while(!Q1.empty())Q1.pop();
	bfs(G1,num1,Q1);
	while(!Q2.empty())Q2.pop();
	bfs(G2,num2,Q2);
	return (ll)Q1.size()==n-1&&(ll)Q2.size()==n-1;
}
int main(){
	scanf("%lld",&T);
	while(T--){
		ans=0;
		scanf("%lld%lld",&n,&m);
		for(int i=0;i<=n;i++)
			for(int j=0;j<=m;j++)
				num1[i][j]=num2[i][j]=0;
		for(int i=0;i<=n;i++)G1[i]=G2[i]=0;
		S=(1ll<<n)-1;
		for(ll i=1;i<=m;i++){
			ll u,v;
			scanf("%lld%lld",&u,&v);
			E[i].u=u,E[i].v=v;
			G1[u]|=(1ll<<(v-1));
			G2[v]|=(1ll<<(u-1));
			num1[u][v]=i,num2[v][u]=i;
		}
		bfs(G1,num1,q1);bfs(G2,num2,q1);
		while(!q1.empty()){
			ll i=q1.front(),u=E[i].u,v=E[i].v;
			q1.pop();
			if(E[i].op!=0)continue;
			E[i].op=1;n1++;
			G1[u]^=(1ll<<(v-1));
			G2[v]^=(1ll<<(u-1));
			if(check()){
				bfs(G1,num1,q2);bfs(G2,num2,q2);
				while(!q2.empty()){
					ll j=q2.front(),u=E[j].u,v=E[j].v;
					q4.push(j);q2.pop();
					if(E[j].op!=0)continue;
					E[j].op=2;n2++;
					G1[u]^=(1ll<<(v-1));
					G2[v]^=(1ll<<(u-1));
					if(check()){
						bfs(G1,num1,q3);bfs(G2,num2,q3);
						while(!q3.empty()){
							ll k=q3.front(),u=E[k].u,v=E[k].v;
							q5.push(k);q3.pop();
							if(E[k].op!=0)continue;
							G1[u]^=(1ll<<(v-1));
							G2[v]^=(1ll<<(u-1));
							E[k].op=3;
							if(!check())ans++;
							G1[u]^=(1ll<<(v-1));
							G2[v]^=(1ll<<(u-1));
						}
						while(!q5.empty()){
							ll k=q5.front();
							q5.pop();
							if(E[k].op==3)E[k].op=0;
						}
					}
					
					else ans+=(m-n1-n2);
					
					G1[u]^=(1ll<<(v-1));
					G2[v]^=(1ll<<(u-1));
					
				}
				while(!q4.empty()){
					ll j=q4.front();
					q4.pop();
					if(E[j].op==2)E[j].op=0;
				}
				n2=0;
			}
			
			else ans+=(ll)(m-n1)*(m-n1-1)/2;
			
			G1[u]^=(1ll<<(v-1));
			G2[v]^=(1ll<<(u-1));
		}
		printf("%lld\n",ans);
	}
}

Details

answer.code: In function ‘int main()’:
answer.code:56:35: error: ‘n1’ was not declared in this scope; did you mean ‘y1’?
   56 |                         E[i].op=1;n1++;
      |                                   ^~
      |                                   y1
answer.code:65:51: error: ‘n2’ was not declared in this scope; did you mean ‘q2’?
   65 |                                         E[j].op=2;n2++;
      |                                                   ^~
      |                                                   q2
answer.code:99:33: error: ‘n2’ was not declared in this scope; did you mean ‘q2’?
   99 |                                 n2=0;
      |                                 ^~
      |                                 q2
answer.code:34:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |         scanf("%lld",&T);
      |         ~~~~~^~~~~~~~~~~
answer.code:37:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |                 scanf("%lld%lld",&n,&m);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~
answer.code:45:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |                         scanf("%lld%lld",&u,&v);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~