QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#99204 | #6308. Magic | ice_cup | WA | 87ms | 6372kb | C++14 | 698b | 2023-04-21 16:56:24 | 2023-04-21 16:56:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int head[10010],cnt,n,ask[10010],mt[10010];
bitset<5010>g[5010];
struct node{
int l,r;
}a[5010];
bool fi(int u){
for(auto v=g[u]._Find_first();v<=n;v=g[u]._Find_next(v)){
if(ask[v])continue;
ask[v]=1;
if(!mt[v]||fi(mt[v])){
mt[v]=u;
return 1;
}
}
return 0;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].l>>a[i].r;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(i==j)continue;
if(a[i].l<a[j].l&&a[j].l<a[i].r&&a[i].r<a[j].r){
g[j][i]=1;
}
}
}
int num=2*n;
for(int i=1;i<=n;i++){
if(mt[i])continue;
memset(ask,0,sizeof(ask));
num-=fi(i);
}
cout<<num;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3308kb
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: 87ms
memory: 6372kb
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:
8470
result:
wrong answer 1st numbers differ - expected: '8134', found: '8470'