QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#178686#6308. MagiccqbzlyWA 55ms6304kbC++231.2kb2023-09-14 11:08:002023-09-14 11:08:01

Judging History

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

  • [2023-09-14 11:08:01]
  • 评测
  • 测评结果:WA
  • 用时:55ms
  • 内存:6304kb
  • [2023-09-14 11:08:00]
  • 提交

answer

#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ll long long
using namespace std;
const int N=5005;
int n,tot,l[N],r[N],match[N];
int px[N],py[N];
bitset<N>to[N],vs;
queue<int>Q;
int bfs(int u){
    while(Q.size())Q.pop();
    vs.set(),Q.push(u);int v=-1;
    vs[u]=0;
    while(Q.size()){
        int x=Q.front();Q.pop();
        bitset<N>tmp=vs&to[x];
        for(int y=tmp._Find_first();y<=n;y=tmp._Find_next(y)){
            int z=match[y];vs[y]=0;
            if(z==0){
                match[y]=x,v=x;
                break;
            }
            Q.push(z),px[z]=x,py[z]=y;
        }if(~v)break;
    }if(v==-1)return 0;
    while(v!=u){
        match[py[v]]=px[v];
        v=px[v];
    }
    return 1;
}
int main(){
    //freopen("data.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>l[i]>>r[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(l[i]<l[j]&&l[j]<r[i]-1&&r[i]-1<r[j]-1){
                to[i][j]=1;
            }
        }
    }
    for(int i=1;i<=n;i++){
        tot+=bfs(i);
    }cout<<2*n-tot;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3572kb

input:

5
2 3
6 7
1 9
5 10
4 8

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: -100
Wrong Answer
time: 55ms
memory: 6304kb

input:

5000
7985 7987
42 46
1591 1593
407 410
6305 6306
1456 1457
5874 5875
7135 7137
7041 7046
6813 6815
8868 8871
665 666
4055 4056
9789 9796
7067 7068
4745 4746
5167 5171
1735 1737
2125 2128
1444 1447
1348 1352
6087 6090
1381 1384
1600 1601
5187 5190
2801 2802
8449 8450
9376 9377
4021 4024
2674 2676
490...

output:

9202

result:

wrong answer 1st numbers differ - expected: '8134', found: '9202'