QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#250843 | #7687. Randias Permutation Task | Lain | RE | 1ms | 3400kb | C++23 | 1.1kb | 2023-11-13 19:36:26 | 2023-11-13 19:36:26 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int n, m;
cin >> m >> n;
vector<vi> a(n, vi(m));
for (auto& x : a) for (auto& y : x) cin >> y, y--;
reverse(a.begin(), a.end());
set<vi> perms;
if (n <= 20) {
for (int mask = 1; mask < (1<<n); mask++) {
vi p(m);
iota(p.begin(), p.end(), 0);
rep(b, 0, n) {
if (mask>>b&1) {
vi q(m);
rep(i, 0, m)
q[i] = a[b][p[i]];
p = std::move(q);
}
}
// Insert q in some set and test??
perms.insert(p);
}
} else {
rep(i, 0, n) {
set<vi> created_set;
for (auto& perm : perms) {
vi res(m);
rep(j, 0, m)
res[i] = a[i][perm[i]];
created_set.insert(res);
}
perms.merge(created_set);
perms.insert(a[i]);
}
}
cout << perms.size() << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3400kb
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: 3368kb
input:
2 1 2 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: -100
Runtime Error
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 ...