QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#549707#7687. Randias Permutation Taskccsurzw#WA 0ms3772kbC++20980b2024-09-06 19:57:262024-09-06 19:57:26

Judging History

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

  • [2024-09-06 19:57:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3772kb
  • [2024-09-06 19:57:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 3;
const int M = 1e7;
const ll INF = 5e18;

int n, m;
ll mod = 1e9 + 7;
ll qpow(ll x, ll y) {
    ll sum = 1;
    while (y) {
        if (y & 1)sum = sum * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return sum;
}
void solve()
{
    cin >> n >> m;
    set<array<int,50>> st;
    array<int,50> a;
    for (int i = 0; i < n; i++)cin >> a[i];
    st.insert(a);
    int cnt = m - 1;
    for (int j = 1; j < m; j++) {
        bool flag = 1;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            if (a[i] != i + 1)flag = 0;
        }
        if(st.find(a) ==st.end())
        st.insert(a);
        if (flag == 1)cnt--;
    }
    cout << (qpow(2, min(cnt, m - 1)) - (m - st.size()) + mod) % mod;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3772kb

input:

2 1
2 1

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3624kb

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:

999999829

result:

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