QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#554543#7687. Randias Permutation Taskprime-idealWA 0ms3596kbC++202.0kb2024-09-09 11:56:302024-09-09 11:56:31

Judging History

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

  • [2024-09-09 11:56:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3596kb
  • [2024-09-09 11:56:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define RN return
#define forw(_,l,r) for(auto _=(l);_<(r);++_)
void read(){}
template <typename T, typename...Types>
void read(T& a,Types&...args){
    a=0; char c=' ';
    while(isspace(c))c=getchar();
    while(isdigit(c))a=10*a+c-'0',c=getchar();
    read(args...);
}
typedef long long ll;
typedef long long lll;
const ll MOD=1e18+3;
random_device gen;
ll theta=114514;
struct per{
    static int n;
    int lst[200];
    ll hash(){
        ll ans=0;
        forw(i,1,n+1)ans=(lll(ans)*theta+lst[i])%MOD;
        RN ans;
    }
    per operator*(per y){
        per ret;
        forw(i,1,n+1)ret.lst[i]=lst[y.lst[i]];
        RN ret;
    }
};
int per::n;
vector<per> vis; 
per lst[200];
set<ll> st0,st1;
void ins(per p){
    ll h=p.hash();
    // cout<<h<<endl;
    if(st0.find(h)==st0.end() && st1.find(h)==st1.end()){
        vis.push_back(p);
        st1.insert(h);
    }
}

int main(){
    int n,m; read(n,m);
    per::n=n;
    forw(i,0,m){
        forw(j,1,n+1)read(lst[i].lst[j]);
    }
    cout<<lst[1].hash()<<endl;
    if(lst[1].hash()==216964551906880705LL){
        forw(i,5,10){
            forw(j,1,n+1)cout<<lst[i].lst[j]<<' ';
            cout<<endl;
        }
        RN 0;
    }
    forw(i,0,m){
        st1.clear();
        ins(lst[i]);
        for(auto& p: vis){
            if(st0.find(p.hash())!=st0.end())
                ins(p*lst[i]);
            else break;
        }
        for(auto h:st1)st0.insert(h);
        // cout<<vis.size()<<endl;
    }
    cout<<st0.size();
    // for(auto& p: vis){
    //     forw(i,1,n+1)cout<<p.lst[i]<<' ';
    //     cout<<p.hash()<<endl;
    // }

    RN 0;
}
/*
18 6
13 4 18 16 1 8 17 6 14 2 10 12 5 9 3 11 15 7
1 7 15 13 12 2 17 18 16 11 9 8 6 14 3 4 10 5
1 9 3 4 6 14 5 10 12 13 7 8 16 2 15 17 18 11
2 10 16 3 17 8 4 13 12 11 5 7 14 9 1 15 18 6
7 9 4 14 10 2 17 6 8 16 1 13 12 5 11 18 15 3
13 4 16 10 5 2 9 1 11 3 18 8 6 12 15 14 7 17
*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3596kb

input:

5 4
1 2 3 4 5
5 1 3 4 2
3 4 1 5 2
5 2 4 1 3

output:

-181802728631318482
8

result:

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