QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#445315#8809. Telephone PlansCrysflyCompile Error//C++172.7kb2024-06-16 01:07:262024-06-16 01:07:27

Judging History

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

  • [2024-06-16 01:07:27]
  • 评测
  • [2024-06-16 01:07:26]
  • 提交

answer

// what is matter? never mind. 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline ll read()
{
    char c=getchar();ll x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 1000005
#define inf 0x3f3f3f3f

int O,n,q;

set<int>e[maxn],c[maxn*2];
struct node{
	int u,pa;
	set<int>::iterator it;
};

ll res1[maxn*3],res2[maxn*3];
int fa[maxn*2],idx;

ll add(int u,int v){
//	cout<<"add "<<u<<" "<<v<<"\n";
	e[u].insert(v),e[v].insert(u);
	int fu=fa[u],fv=fa[v];
	if(c[fu].size()<c[fv].size()) swap(u,v),swap(fu,fv);
	
	ll ans=1ll*c[fu].size()*c[fv].size();
	for(int x:c[fv]) c[fu].insert(x),fa[x]=fu;
	c[fv].clear();
//	cout<<"ans "<<ans<<"\n";
	return ans;
}

queue<node>q[2];
vi s[2];
ll del(int u,int v){
	e[u].erase(v),e[v].erase(u);
	
	while(q[0].size()) q[0].pop();
	while(q[1].size()) q[1].pop();
	s[0].pb(u),s[1].pb(v);
	if(e[u].size()) q[0].push((node){u,0,e[u].begin()});
	if(e[v].size()) q[1].push((node){v,0,e[v].begin()});
	
	while(q[0].size() && q[1].size()) {
		int o=(s[1].size()<s[0].size());
		auto [u,pa,it]=q[o].front(); q[o].pop();
		int v=*it;
		if(v!=pa){
			s[o].pb(v);
			if(e[v].size()) q[o].push({v,u,e[v].begin()});
		}
		++it;
		if(it==e[u].end()) continue;
		if(*it==pa) ++it;
		if(it==e[u].end()) continue;
		q[o].push({u,pa,it});
	}
	if(!q[0].size() && (q[1].size() || s[0].size()<s[1].size())) swap(u,v),swap(s[0],s[1]);
	
	int fu=fa[u];
	ll ans=1ll*s[1].size()*(c[fu].size()-s[1].size());
	assert(s[1].size()*2<=c[fu].size());
	
	++idx;
	for(int x:s[1]) fa[x]=idx,c[fu].erase(x),c[idx].insert(x);
	
	return ans;
}

signed main()
{
//	freopen("my.out","w",stdout);
	O=read(),n=read(),q=read(); idx=n;
	For(i,1,n) c[i].insert(i);
	For(i,1,n*2) fa[i]=i;
	ll lst=0;
	For(i,1,q){
		int op=read();
		res1[i]=res1[i-1],res2[i]=res2[i-1];
		if(op==1){
			int u=read(),v=read();
			if(O)u^=lst,v^=lst;
			res1[i]+=add(u,v);
		}
		if(op==2){
			int u=read(),v=read();
			if(O)u^=lst,v^=lst;
			res2[i]+=del(u,v);
		}
		if(op==3){
			ll t=read();
			if(O)t^=lst;
			lst=res1[i]-res2[i-t];
			cout<<lst<<"\n";
		}
	}
	return 0;
}
/*
*/

详细

answer.code:56:12: error: conflicting declaration ‘std::queue<node> q [2]’
   56 | queue<node>q[2];
      |            ^
answer.code:32:9: note: previous declaration as ‘int q’
   32 | int O,n,q;
      |         ^
answer.code: In function ‘long long int del(int, int)’:
answer.code:61:16: error: invalid types ‘int[int]’ for array subscript
   61 |         while(q[0].size()) q[0].pop();
      |                ^
answer.code:61:29: error: invalid types ‘int[int]’ for array subscript
   61 |         while(q[0].size()) q[0].pop();
      |                             ^
answer.code:62:16: error: invalid types ‘int[int]’ for array subscript
   62 |         while(q[1].size()) q[1].pop();
      |                ^
answer.code:62:29: error: invalid types ‘int[int]’ for array subscript
   62 |         while(q[1].size()) q[1].pop();
      |                             ^
answer.code:64:26: error: invalid types ‘int[int]’ for array subscript
   64 |         if(e[u].size()) q[0].push((node){u,0,e[u].begin()});
      |                          ^
answer.code:65:26: error: invalid types ‘int[int]’ for array subscript
   65 |         if(e[v].size()) q[1].push((node){v,0,e[v].begin()});
      |                          ^
answer.code:67:16: error: invalid types ‘int[int]’ for array subscript
   67 |         while(q[0].size() && q[1].size()) {
      |                ^
answer.code:67:31: error: invalid types ‘int[int]’ for array subscript
   67 |         while(q[0].size() && q[1].size()) {
      |                               ^
answer.code:69:33: error: invalid types ‘int[int]’ for array subscript
   69 |                 auto [u,pa,it]=q[o].front(); q[o].pop();
      |                                 ^
answer.code:69:47: error: invalid types ‘int[int]’ for array subscript
   69 |                 auto [u,pa,it]=q[o].front(); q[o].pop();
      |                                               ^
answer.code:73:42: error: invalid types ‘int[int]’ for array subscript
   73 |                         if(e[v].size()) q[o].push({v,u,e[v].begin()});
      |                                          ^
answer.code:79:18: error: invalid types ‘int[int]’ for array subscript
   79 |                 q[o].push({u,pa,it});
      |                  ^
answer.code:81:14: error: invalid types ‘int[int]’ for array subscript
   81 |         if(!q[0].size() && (q[1].size() || s[0].size()<s[1].size())) swap(u,v),swap(s[0],s[1]);
      |              ^
answer.code:81:30: error: invalid types ‘int[int]’ for array subscript
   81 |         if(!q[0].size() && (q[1].size() || s[0].size()<s[1].size())) swap(u,v),swap(s[0],s[1]);
      |                              ^