QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#606723 | #9310. Permutation Counting 4 | KIRITO1211 | TL | 1740ms | 18872kb | C++23 | 1.8kb | 2024-10-03 11:48:49 | 2024-10-03 11:48:50 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while(t--){
int n;
cin >> n;
// 构建连接矩阵
vector<vector<int>> adj(n, vector<int>(n, 0));
for(int i=0; i<n; ++i){
int l, r;
cin >> l >> r;
// 将允许的范围设置为1
for(int j=l-1; j<r; ++j){
adj[i][j] = 1;
}
}
// 计算行列式的值
// 使用高斯消元法
int det = 1;
for(int i=0; i<n && det; ++i){
// 寻找主元
int pivot = -1;
for(int j=i; j<n; ++j){
if(adj[j][i]){
pivot = j;
break;
}
}
if(pivot == -1){
det = 0;
break;
}
if(pivot != i){
swap(adj[i], adj[pivot]);
det = (det * 1) % 2; // 交换行改变行列式符号,但在模2下无影响
}
// 消元
for(int j=i+1; j<n; ++j){
if(adj[j][i]){
for(int k=i; k<n; ++k){
adj[j][k] ^= adj[i][k];
}
}
}
}
// 检查是否有零行
for(int i=0; i<n; ++i){
bool all_zero = true;
for(int j=0; j<n; ++j){
if(adj[i][j]){
all_zero = false;
break;
}
}
if(all_zero){
det = 0;
break;
}
}
cout << det % 2 << "\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3528kb
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
output:
0 1 0 0
result:
ok 4 tokens
Test #2:
score: 0
Accepted
time: 132ms
memory: 3844kb
input:
66725 14 7 7 4 6 7 8 8 13 2 13 6 13 6 10 14 14 1 10 9 11 7 9 3 8 4 12 5 12 12 2 6 3 6 7 11 2 5 1 1 6 12 8 12 2 3 7 9 7 8 1 10 1 4 10 4 8 4 4 6 10 9 10 2 3 2 7 1 3 3 4 2 2 3 10 20 3 12 10 14 19 20 19 20 1 9 7 9 13 16 17 17 16 18 2 11 5 19 6 17 11 17 3 6 3 11 7 20 8 17 3 18 10 15 9 20 16 5 10 2 10 2 1...
output:
1 1 0 0 1 0 1 1 0 1 1 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 1 0 0 0 0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 1 0 1 1 0 1 1 1 0 1 0 1 0 0 0 1 1 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 1 1 0 0 1 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 1 0 0 1 0 1 1 ...
result:
ok 66725 tokens
Test #3:
score: 0
Accepted
time: 275ms
memory: 3936kb
input:
6655 155 28 58 68 100 6 47 98 109 11 133 38 153 73 118 126 153 24 43 71 118 109 135 6 104 40 101 24 139 100 136 135 136 40 148 70 117 92 124 63 64 45 55 16 128 65 86 20 49 126 138 30 141 127 146 21 155 49 139 27 34 39 145 20 53 12 41 3 107 38 78 106 109 61 102 20 99 134 135 23 99 10 69 105 113 36 75...
output:
0 0 1 1 0 1 0 0 1 1 0 1 1 1 0 0 1 1 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 0 1 1 0 1 0 1 0 1 0 1 1 1 1 0 1 0 0 0 0 0 1 1 0 1 0 1 0 1 0 1 0 0 1 0 0 1 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 1 0 0 0 0 ...
result:
ok 6655 tokens
Test #4:
score: 0
Accepted
time: 1740ms
memory: 18872kb
input:
666 1967 396 1664 818 1954 564 805 1106 1322 568 1687 853 1482 153 1092 566 670 154 562 114 1372 574 1879 482 1083 499 1566 2 1384 291 1947 122 1714 1277 1900 740 1024 887 1478 146 254 944 1807 574 1193 225 1933 43 1278 1017 1482 958 1180 86 1230 1658 1679 980 1542 1044 1127 762 989 1128 1567 552 17...
output:
0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 0 1 0 0 0 0 1 1 0 0 1 0 1 1 0 1 0 0 1 1 1 1 1 0 1 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 1 1 1 1 0 1 1 0 1 0 0 1 1 1 1 1 0 0 1 1 0 0 1 0 0 1 0 1 1 0 1 1 1 1 1 1 0 0 0 0 1 1 0 ...
result:
ok 666 tokens
Test #5:
score: -100
Time Limit Exceeded
input:
67 12220 945 3456 3457 11698 945 3023 945 10249 945 6035 3457 12211 3024 9082 6554 10249 3179 11698 945 2449 3457 6897 945 3625 4115 9082 3626 11593 2450 3525 3526 5410 3179 5606 5607 8510 5607 8159 1908 9082 6898 9270 3457 4922 6669 9082 2936 10249 2936 9009 1796 5410 4923 10474 2450 5488 3526 6232...