QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#569474 | #9310. Permutation Counting 4 | KobicGend | RE | 0ms | 0kb | C++20 | 1.6kb | 2024-09-16 23:25:56 | 2024-09-16 23:25:56 |
Judging History
answer
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <array>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
using ll = long long;
#include <vector>
#include <numeric>
struct DSU {
vector<int> p, siz;
DSU() {}
DSU(int n) {
init(n);
}
void init(int n) {
p.resize(n + 1);
iota(p.begin(), p.end(), 0);
siz.assign(n + 1, 1);
}
int find(int x) {
while (x != p[x]) x = p[x] = p[p[x]]; // 路径压缩
return x;
}
bool same(int x, int y) {
return find(x) == find(y);
}
bool uno(int x, int y) {
x = find(x), y = find(y);
if (same(x, y)) return false;
siz[x] += siz[y];
p[y] = x;
return true;
}
int size(int x) {
return siz[find(x)];
}
};
int read() {
char u, v;
cin >> u >> v;
return (u - 48) * 50 + v - 48;
}
void eachT() {
int n;
cin >> n;
vector<vector<int>> v(n + 2);
for (int i = 0; i < n; ++i) {
int l, r;
cin >> l >> r;
v[l].push_back(r);
}
bool ok = 1;
for (int l = 1; l <= n; ++l) {
if (v[l].empty()) {
ok = 0;
}
sort(v[l].begin(), v[l].end(), greater<>());
int big = v[l][0];
for (int j = 1; j < v[l].size(); ++j) {
if (v[l][j - 1] == v[l][j]) {
ok = 0;
}
int r = v[l][j];
v[r + 1].push_back(big);
}
}
cout << ok << '\n';
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
cin >> T;
while (T--) {
eachT();
}
return 0;
}
详细
Test #1:
score: 0
Runtime Error
input:
4 5 1 2 1 5 1 2 1 2 2 2 5 1 1 2 4 2 3 5 5 3 4 5 3 5 1 2 3 4 3 5 3 3 5 1 5 1 4 4 5 5 5 1 2