QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#244289 | #7687. Randias Permutation Task | ucup-team2432# | RE | 1ms | 3508kb | C++20 | 1.4kb | 2023-11-08 22:52:02 | 2023-11-08 22:52:03 |
Judging History
answer
#include<bits/stdc++.h>
using LL = long long;
const LL inf = 1e9;
const LL P[2] = {1000000007,1000000009};
const LL K = 114514;
void solve() {
std::mt19937 rnd(std::random_device{}());
int n,m;std::cin >> n >> m;
std::vector pmt(m,std::vector<int>(n));
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
std::cin >> pmt[i][j];
}
}
std::shuffle(pmt.begin(),pmt.end(),rnd);
std::map<std::vector<int>,int> mp;
std::priority_queue<std::pair<int,std::vector<int>>,std::vector<std::pair<int,std::vector<int>>>,std::greater<>> q;
for (int i = 0; i < m; ++i) {
pmt[i][n] = i;
q.emplace(i+1,pmt[i]);
}
while (!q.empty()) {
auto [point,vec] = q.top();q.pop();
if (!mp.count(vec)) {
mp[vec] = point+1;
} else {
if (mp[vec]+1 < point) {
continue;
}
}
if (point == m) continue;
q.emplace(point+1,vec);
for (int i = 0; i < n; ++i) {
vec[i] = pmt[point][vec[i] - 1];
}
q.emplace(point+1,vec);
}
std::cout << mp.size();
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
// clock_t st = clock();
// std::cout << std::fixed << std::setprecision(12);
// freopen("test.in", "r", stdin);
// freopen("test.out", "w", stdout);
int T = 1;
// std::cin >> T;
while (T --) {
solve();
}
// std::cout << (double)(clock()-st)/CLOCKS_PER_SEC;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3424kb
input:
5 4 1 2 3 4 5 5 1 3 4 2 3 4 1 5 2 5 2 4 1 3
output:
8
result:
ok 1 number(s): "8"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
2 1 2 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3488kb
input:
1 180 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3508kb
input:
180 1 52 71 167 89 165 102 119 125 9 128 180 24 48 172 108 22 164 28 159 111 30 91 67 51 136 97 126 133 177 65 115 157 114 11 171 178 23 127 163 103 99 18 56 94 176 77 44 1 124 74 61 87 4 40 63 92 169 84 146 6 88 55 152 49 10 90 43 174 70 50 69 154 73 147 110 20 82 59 112 12 64 143 16 138 5 170 155 ...
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3452kb
input:
2 90 1 2 1 2 1 2 1 2 2 1 2 1 2 1 2 1 1 2 2 1 1 2 1 2 1 2 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 2 1 1 2 2 1 1 2 1 2 1 2 2 1 2 1 1 2 2 1 1 2 2 1 1 2 1 2 2 1 1 2 2 1 2 1 2 1 2 1 1 2 2 1 2 1 2 1 2 1 1 2 1 2 2 1 2 1 1 2 1 2 1 2 2 1 1 2 2 1 2 1 1 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 2 1 1 2 1 2 2 1 1 2 1 2...
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: -100
Runtime Error
input:
90 2 43 44 28 69 66 18 5 23 87 8 24 89 31 29 81 1 68 2 78 53 49 54 4 13 77 61 33 57 63 85 55 79 46 35 45 64 65 42 30 6 19 74 82 80 17 26 32 59 7 72 16 3 47 73 39 36 25 34 56 86 71 62 84 40 41 11 50 27 20 14 37 12 38 58 48 83 76 70 51 88 22 90 21 9 10 60 15 52 75 67 9 73 52 51 81 16 71 77 6 57 11 75 ...