QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#327902#1844. Cactusxztmax67Compile Error//C++142.0kb2024-02-15 15:27:582024-02-15 15:27:59

Judging History

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

  • [2024-02-15 15:27:59]
  • 评测
  • [2024-02-15 15:27:58]
  • 提交

answer

#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define mk make_pair
#define pb push_Back
using namespace std;
const int N=1e6+100;
int n,m;
vector<int>ans,g[N],G[N];
int vis[N],deg[N];
void dfs(int x)
{
	vis[x]=1;ans.push_back(x);deg[x]=0;
	for(auto y:g[x])if(!vis[y])deg[y]^=1;
	for(auto y:g[x])if(!vis[y]&&deg[y])dfs(y);
}
int dfn[N],low[N],dfntot,scc;
stack<int>st;
void tarjan(int x)
{
	dfn[x]=low[x]=++dfntot;st.push(x);
	for(auto y:G[x])
	{
		if(!dfn[y])
		{
			tarjan(y);if(low[y]>=dfn[x])
			{
				scc++;int z;
				do{z=st.top();st.pop();g[scc].push_back(z);g[st.top()].push_back(z);}while(z!=y)
				g[scc].push_back(x);g[x].push_back(scc);
			}
			else low[x]=min(low[x],low[y]);
		}
		else low[x]=min(low[x],dfn[y]);
	}
}
void dfs(int x,int fa)
{
	vis[x]=1;
	for(auto y:g[x])if(y!=fa)dfs(y,x);
//	cout<<x<<" "<<fa<<endl;
	if(x<=n){if(!fa)ans.push_back(x);return;}
	int p=0,sz=g[x].size();
	for(int i=0;i<sz;i++)if(g[x][i]==fa)p=i;
//	for(auto y:g[x])cout<<y<<' ';cout<<endl;
	for(int i=1;i<sz;i++)
		if(i&1)ans.push_back(g[x][(p+i)%sz]);
		else ans.push_back(g[x][(p+i)%sz]+n);
	if(sz&1)ans.push_back(g[x][(p+1)%sz]+n),ans.push_back(g[x][(p-1+sz)%sz]);
	else ans.push_back(g[x][(p+1)%sz]+n),ans.push_back(g[x][(p-1+sz)%sz]+n);
}
signed main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m;scc=n;
	for(int i=1,x,y;i<=m;i++)cin>>x>>y,g[x].push_back(y),g[y].push_back(x),deg[x]^=1,deg[y]^=1;
	for(int i=1;i<=n;i++)if(deg[i])dfs(i);
	for(int x=1;x<=n;x++)for(auto y:g[x])if(!vis[x]&&!vis[y])G[x].push_back(y);
	for(int i=1;i<=n;i++)g[i].clear();
	for(int i=1;i<=n;i++)if(G[i].size()&1)puts("SB");
	ans.push_back(0);
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;i++)if(!dfn[i])tarjan(i);
	for(int i=1;i<=n;i++)if(!vis[i])dfs(i,0);
	cout<<0<<" "<<ans.size()<<endl;
	for(auto x:ans)if(!x)cout<<2<<endl;else cout<<1<<" "<<x<<endl;
	return 0;
}
/*
6 6
1 2
2 3
3 4
4 5
5 6
6 1
*/

Details

answer.code: In function ‘void tarjan(int)’:
answer.code:30:113: error: expected ‘;’ before ‘g’
   30 |                                 do{z=st.top();st.pop();g[scc].push_back(z);g[st.top()].push_back(z);}while(z!=y)
      |                                                                                                                 ^
      |                                                                                                                 ;
   31 |                                 g[scc].push_back(x);g[x].push_back(scc);
      |                                 ~