QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#250016#7687. Randias Permutation TaskXHYMathematicsWA 0ms3628kbC++231.6kb2023-11-12 20:18:162023-11-12 20:18:16

Judging History

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

  • [2023-11-12 20:18:16]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2023-11-12 20:18:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define string basic_string<int>
constexpr ll N=180;
string a[N],sk;
set<string>ans;
vector<int>c;
ll n,m;
inline string solveans()
{
    ll k=c.size(),i,j;
    string ans=a[c[k-1]];
    for(i=k-2;i>=0;i--)
    {
        for(j=0;j<n;j++)ans[j]=a[c[i]][ans[j]-1];
    }
    return ans;
}
inline void dfs(ll x,ll cnt)
{
    if(cnt)ans.insert(solveans());
    if(cnt>=m)return;
    ll i;
    for(i=x;i<m;i++)
    {
        c.push_back(i);
        dfs(i+1,cnt+1);
        c.pop_back();
    }
}
inline string operator^(const string &a,const string &b)
{
    ll n=a.size(),i;
    string c;
    c.resize(n);
    for(i=0;i<n;i++)c[i]=a[b[i]-1];
    return c;
}
inline set<string>solve(ll l,ll r)
{
    if(r-l<=1)return {a[l]};
    ll mid=(l+r)>>1;
    set<string>res,al,ar;
    string s;
    al=solve(l,mid),ar=solve(mid,r);
    for(auto&&i:al)res.insert(i);
    for(auto&&i:ar)res.insert(i);
    for(auto&&i:al)
    {
        for(auto&&j:ar)
        {
            s=i^j;
            res.insert(s);
            s=j^i;
            res.insert(s);
        }
    }
    return res;
}
int main()
{
    ll i,j;
    ios::sync_with_stdio(0),cin.tie(0);
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        a[i].resize(n);
        for(j=0;j<n;j++)cin>>a[i][j],a[i][j]-='0';
    }
    if(m<=20)
    {
        dfs(0,0);
        cout<<ans.size()<<'\n';
    }
    else
    {
        sk.resize(n);
        iota(sk.begin(),sk.end(),1);
        ll sum=solve(0,m).size();
        cout<<sum<<'\n';
    }
    return 0;
}

详细

Test #1:

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

input:

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

output:

5

result:

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