QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#617103#6308. MagicfryanWA 73ms6824kbC++17935b2024-10-06 13:53:592024-10-06 13:54:01

Judging History

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

  • [2024-10-06 13:54:01]
  • 评测
  • 测评结果:WA
  • 用时:73ms
  • 内存:6824kb
  • [2024-10-06 13:53:59]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
mt19937 rng(1);

const int mxn = 5e3+5;

int n;
int l[mxn], r[mxn];
bitset<mxn> adj[mxn],used;

int mt[mxn];

int kuhn(int v) {
	used.reset(v);
	bitset<mxn> nx = adj[v];
	nx &= used;
	for (int i=nx._Find_first(); i < nx.size(); i = nx._Find_next(i)) {
		used.reset(i);
		if (mt[i]==-1 || kuhn(mt[i])) {
			mt[i] = v;
			return 1;
		}
		nx &= used;
	}
	return 0;
}

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	
	cin>>n;
	
	for (int i=0; i<n; i++) {
		cin>>l[i]>>r[i];
		adj[i].reset();
	}
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			if (l[i] < l[j] && r[i] > l[j] && r[i] < r[j])
				adj[j].set(i);
		}
	}
	int cnt = 2*n;

	memset(mt,-1,sizeof(mt));
	for (int v=0; v<n; v++) {
		used.set();
		cnt -= kuhn(v);
	}
	
	cout<<cnt;
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3640kb

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: 73ms
memory: 6824kb

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:

8192

result:

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