QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#234155#4934. Forbidden CardfansizheRE 0ms0kbC++141.0kb2023-11-01 14:36:312023-11-01 14:36:31

Judging History

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

  • [2023-11-01 14:36:31]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-11-01 14:36:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int read(){
    int x=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=x*10+(c^'0'),c=getchar();
    return x;
}
int n,m;
int a[200005],b[200005];
int vis[1000005],num[1000005];
int ans[200005];
int main(){
    freopen("marketplace.in","r",stdin);
    freopen("marketplace.out","w",stdout);
    n=read(),m=read();
    for(int i=1;i<=n;i++)a[i]=read(),b[i]=read();
    for(int i=n+1;i<=2*n;i++)a[i]=a[i-n],b[i]=b[i-n];
    a[2*n+1]=a[1],b[2*n+1]=b[1];
    for(int i=1;i<=m;i++)num[i]=1;
    int now=m;
    for(int i=1;i<=2*n+1;i++){
        if(!vis[a[i]]){
            vis[a[i]]=1;
            if(vis[b[i]])ans[i]=num[a[i]],now-=num[a[i]];
            else num[b[i]]+=num[a[i]];
        }else if(!vis[b[i]]){
            vis[b[i]]=1;
            ans[i]=num[b[i]],now-=num[b[i]];
        }else{ans[i]=now;break;}
    }
    printf("%d\n",ans[1]+ans[n+1]+ans[2*n+1]);
    for(int i=2;i<=n;i++)printf("%d\n",ans[i]+ans[n+i]);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

3 6
1 2
2 4
4 2

output:


result: