QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#107132#6308. MagicnumberesWA 67ms6660kbC++201.4kb2023-05-20 13:56:572023-05-20 13:56:58

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-20 13:56:58]
  • 评测
  • 测评结果:WA
  • 用时:67ms
  • 内存:6660kb
  • [2023-05-20 13:56:57]
  • 提交

answer

/**
 * @date    2023-05-20 10:48:58
 * RAmen!
 */
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define ll long long
using namespace std;
int n;
int l[5005], r[5005];
bitset<5005> g[5005];
bitset<5005> vis, cur;
int mat[5005], prv[5005];
bool bfs(int s) {
    queue<int> q; q.push(s); vis.set(); prv[s] = -1;
    while(!q.empty()) {
        int u = q.front(); q.pop(); cur = vis & g[u]; bool f = 0;
        for(int v = cur._Find_first(); v <= n; v = cur._Find_next(v)) {
            vis[v] = 0;
            if(mat[v] > 0) {
                q.push(mat[v]); prv[mat[v]] = u;
            }
            else {
                f = 1; int a = u, b = v;
                while(a != -1) {
                    int tmp = mat[a];
                    mat[a] = b;
                    a = prv[a]; b = tmp;
                }
            }
        }
        if(f) break;
    }
    return mat[s] > 0;
}
int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%d %d", &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] && r[i] < r[j])
                g[j][i] = 1;
    int ans = n * 2;
    for(int i = 1; i <= n; i++)
        if(!mat[i])
            ans -= bfs(i);
    printf("%d\n", ans);
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
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: 67ms
memory: 6660kb

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:

8309

result:

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