QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#327654#1844. CactuszyxawaWA 4ms36756kbC++141.8kb2024-02-15 11:45:002024-02-15 11:45:01

Judging History

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

  • [2024-02-15 11:45:01]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:36756kb
  • [2024-02-15 11:45:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define add(x) ans.push_back(x)
int n,m,u,v,tot,cnt,top,stk[300001],deg[300001],vis[300001],dfn[300001],low[300001],s[300001];
vector <int> ans,G[300001],W[300001],E[600001];
void del(int x){
    vis[x]=1,add(x);
    for(auto y:W[x]) deg[y]^=1;
    for(auto y:W[x]) if(deg[y]&&!vis[y]) del(y);
}
void tarjan(int u,int x){
    dfn[u]=low[u]=++tot,stk[++top]=u;
    for(auto v:G[u]){
        if(!dfn[v]){
            tarjan(v,u),low[u]=min(low[u],low[v]);
            if(dfn[u]<=low[v]){
                E[++cnt].push_back(u),E[u].push_back(cnt);
                while(stk[top+1]!=v) E[stk[top]].push_back(cnt),E[cnt].push_back(stk[top--]);
            }
        }
        else if(v!=x) low[u]=min(low[u],dfn[v]);
    }
}
void dfs(int x,int lst){
    vis[x]=1;
    for(auto y:E[x]) if(!vis[y]) dfs(y,x);
    if(E[x].empty()) add(x);
    if(x<=n) return;
    int len=0,str=0;
    for(int i=0;i<E[x].size();i++) if(E[x][i]==lst) str=i;
    for(int i=str;i<E[x].size();i++) s[++len]=E[x][i];
    for(int i=0;i<str;i++) s[++len]=E[x][i];
    for(int i=2;i<=len;i++) add(s[i]+(i&1)*n);
    if(E[x].size()&1) add(s[2]+n),add(s[1]+n),add(s[len]);
    else add(s[1]+n);
}
int main(){
	scanf("%d%d",&n,&m),cnt=n;
    for(int i=1;i<=m;i++){
        scanf("%d%d",&u,&v);
        W[u].push_back(v),deg[u]^=1;
        W[v].push_back(u),deg[v]^=1;
    }
    for(int i=1;i<=n;i++) if(deg[i]) del(i);
    for(int i=1;i<=n;i++) for(auto j:W[i]) if(!vis[i]&&!vis[j]) G[i].push_back(j);
    memset(vis,0,sizeof(vis)),add(0);
    for(int i=1;i<=n;i++) if(!dfn[i]) tarjan(i,0);
    for(int i=1;i<=n;i++) if(!vis[i]) dfs(i,0);
    printf("0 %ld\n",ans.size());int w=0;
    for(auto i:ans){w++;
        if(i!=0) printf("1 %d\n",i);
        else printf("2 %d\n",w);
    }
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 36756kb

input:

3 3
1 2
1 3
2 3

output:

0 6
2 1
1 3
1 5
1 6
1 4
1 2

result:

wrong answer Integer parameter [name=op[3]] equals to 3, violates the range [1, 2]