QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#328066#1844. Cactus11d10xyWA 28ms96076kbC++141.0kb2024-02-15 16:44:532024-02-15 16:44:54

Judging History

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

  • [2024-02-15 16:44:54]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:96076kb
  • [2024-02-15 16:44:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m,tot,st[300010],vis[300010],tp;
set<int>G[300010];
basic_string<int>ans,cir[300010];
void dfs(int u,int fa){
   st[++tp]=u,vis[u]=1;
   for(int v:G[u])if(v!=fa)if(!vis[v]){
      dfs(v,u);
      if(cir[u].empty())continue;
      cir[u].pop_back();
      int s=cir[u].size();
      for(int i=0;i<s;i++)ans+=cir[u][i]+(i&1)*n;
      for(int i=0;i<s;i++)ans+=cir[u][i]+(~i&1)*n;
   }else{cir[v]={};for(int i=tp;st[i+1]!=v;cir[v]+=st[i--]);G[v].erase(u);}
   tp--;
}
int main(){
   cin>>n>>m;
   for(int u,v;m--;)scanf("%d%d",&u,&v),G[u].insert(v),G[v].insert(u);
   set<int>s;
   for(int i=1;i<=n;i++)if(G[i].size()&1)s.insert(i);
   for(int u;!s.empty();){
      u=*begin(s),s.erase(u),ans+=u;
      for(int v:G[u]){
         if(G[v].size()&1)s.erase(v);
         else s.insert(v);
         G[v].erase(u);
      }
   }
   ans+=0;
   for(int i=1;i<=n;i++)if(!vis[i])dfs(i,0),ans+=i;
   printf("0 %d\n",(int)ans.size());
   for(int x:ans)if(x)printf("1 %d\n",x);else puts("2");
   return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 29424kb

input:

3 3
1 2
1 3
2 3

output:

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

result:

ok You are right!

Test #2:

score: -100
Wrong Answer
time: 28ms
memory: 96076kb

input:

7 7
1 2
1 3
2 3
2 4
2 5
3 6
3 7

output:

0 10
1 4
1 2
1 1
1 6
1 3
2
1 1
1 2
1 4
1 6

result:

wrong answer The number of remaining edges is not equal to m'.