QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#615283 | #9449. New School Term | ucup-team3474# | WA | 0ms | 15396kb | C++20 | 1.3kb | 2024-10-05 17:59:50 | 2024-10-05 18:00:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1919810;
typedef long long ll;
typedef pair<ll,ll> PII;
ll n,m,k;
ll a[N],b[N];
char s[N];
int tf[N];
int main(){
cin>>n>>m;
memset(tf,false,sizeof tf);
for(int i=1;i<=m;i++) scanf("%d%d",&a[i],&b[i]);
int cnt0=n,cnt1=n;
for(int i=m;i>=1;i--){
int u=a[i],v=b[i];
if(tf[u]==-1&&tf[v]==-1){
if(cnt0>0&&cnt1>0){
tf[u]=0,tf[v]=1;
cnt0--,cnt1--;
}else if(cnt0>0){
tf[u]=0,tf[v]=0;
cnt0--,cnt0--;
}else{
tf[u]=1,tf[v]=1;
cnt1--,cnt1--;
}
}else if(tf[u]==-1||tf[v]==-1){
if(tf[v]==-1) swap(u,v);
if(tf[v]==1){
if(cnt0) tf[u]=0,cnt0--;
else tf[u]=1,cnt1--;
}else{
if(cnt1) tf[u]=1,cnt1--;
else tf[u]=0,cnt0--;
}
}
}
for(int i=1;i<=2*n;i++){
if(tf[i]==0) cnt0--;
else if(tf[i]==1) cnt1--;
}
for(int i=1;i<=n*2;i++){
if(tf[i]!=-1) continue;
if(cnt0>0) tf[i]=0;
else tf[i]=1;
}
for(int i=1;i<=n*2;i++) cout<<tf[i];
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 15396kb
input:
2 4 1 3 2 4 1 4 1 2
output:
0000
result:
wrong answer The number of 0s must be equal to that of 1s.