QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#238426#7687. Randias Permutation Taskucup-team2307#WA 0ms3648kbC++141.3kb2023-11-04 16:42:412023-11-04 16:42:43

Judging History

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

  • [2023-11-04 16:42:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3648kb
  • [2023-11-04 16:42:41]
  • 提交

answer

#include<bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
mt19937 rng(123);

vector<int> comb(const vector<int> &A, vector<int> B) {
    for(int i = 0; i < A.size(); i++)
        B[i] = A[B[i]];
    return B;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(m);
    for(auto &i : a) {
        i.resize(n);
        for(auto &j : i) cin >> j, --j;
        // iota(all(i), 0);
        // shuffle(all(i), rng);
    }
    vector<int> id(n);
    iota(all(id), 0);
    if(m <= 20) {
        cerr << "pt1"<<endl;
        vector<vector<int>> al;
        for(int msk = 0; msk < 1 << m; msk++) {
            vector<int> cur = id;
            for(int i = 0; i < m; i++)
                if((msk >> i) & 1)
                    cur = comb(cur, a[i]);
            al.push_back(cur);
        }
        sort(all(al));
        cout << unique(all(al)) - al.begin() << endl;
    } else {
        cerr << "pt2"<<endl;
        // vector<vector<int>> 
        set<vector<int>> can;
        can.insert(id);
        for(auto &i : a) {
            set<vector<int>> nc = can;
            for(auto j : can)
                nc.insert(comb(j, i));
            can = nc;
        }
        cout << can.size() << '\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: -100
Wrong Answer
time: 0ms
memory: 3648kb

input:

2 1
2 1

output:

2

result:

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