QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#318700#5533. Trickminhnhatnoe0 26ms3812kbC++142.1kb2024-01-31 17:24:342024-01-31 17:24:34

Judging History

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

  • [2024-01-31 17:24:34]
  • 评测
  • 测评结果:0
  • 用时:26ms
  • 内存:3812kb
  • [2024-01-31 17:24:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<int> gperm(int n){
    vector<int> p(2*n+1); iota(p.begin(), p.end(), 0);
    shuffle(p.begin(), p.end(), mt19937(11092001));
    return p;
}
struct cplayer{
    cplayer(){
        int n; cin >> n;
        vector<int> p = gperm(n);
        vector<int> a(n), b(n);
        vector<pair<int, int>> b_sorted(n);
        for (int i=0; i<n; i++){
            cin >> a[i];
            b[i] = p[a[i]];
            b_sorted[i] = {b[i], i};
        }
        sort(b_sorted.begin(), b_sorted.end());
        int x = 0;
        for (int i=0; i<n; i++) x = (x + b[i]) % p.size();

        for (int i=0; i<n; i++){
            int y = (x + p.size() - b[i]) % p.size();
            int y1 = y % (n+1), y2 = y / (n+1);
            auto it = lower_bound(b_sorted.begin(), b_sorted.end(), pair<int, int> (y1, -1));
            if (it == b_sorted.end() || it->first != y1 || it->second == i) continue;
            
            int xx = a[i], yy = a[it->second];
            if (xx > yy) swap(xx, yy); // xx < yy
            if (y2) swap(xx, yy);
            cout << xx << " " << yy << "\n";
            return;
        }
    }
};

struct hplayer{
    hplayer(){
        int n; cin >> n;
        vector<int> p = gperm(n);
        
        int v = 0;
        for (int i=0; i<p.size(); i++){
            v = (v + p[i]) % p.size();
        }

        for (int i=0; i<2; i++){
            int xx, yy; cin >> xx >> yy;
            v -= p[xx] + p[yy];
            if (xx > yy) v -= n+1;
        }

        v = (v % signed(p.size()) + signed(p.size())) % p.size();
        cout << find(p.begin(), p.end(), v) - p.begin() << "\n";
    }
};
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    // freopen("trick.in", "r", stdin);
    // freopen("trick.out", "w", stdout);

    int t, r; cin >> t >> r;
    if (r == 1 || r == 2){
        for (int i=0; i<t; i++){
            cplayer();
        }
    }
    else{
        for (int i=0; i<t; i++){
            hplayer();
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 26ms = 0ms + 26ms
memory: 0kb,3812kb

input:

12012
1
6
0 1 2 3 4 5
6
0 1 2 3 4 5
6
0 1 2 3 4 5
6
0 1 2 3 4 5
6
0 1 2 3 4 5
6
0 1 2 3 4 5
6
0 1 2 3 4 5
6
0 1 2 3 4 6
6
0 1 2 3 4 6
6
0 1 2 3 4 6
6
0 1 2 3 4 6
6
0 1 2 3 4 6
6
0 1 2 3 4 6
6
0 1 2 3 4 6
6
0 1 2 3 5 6
6
0 1 2 3 5 6
6
0 1 2 3 5 6
6
0 1 2 3 5 6
6
0 1 2 3 5 6
6
0 1 2 3 5 6
6
0 1 2 3 5 ...

output:

0 3
0 3
0 3
0 3
0 3
0 3
0 3
1 4
1 4
1 4
1 4
1 4
1 4
1 4
1 5
1 5
1 5
1 5
1 5
1 5
1 5
0 6
0 6
0 6
0 6
0 6
0 6
0 6
4 5
4 5
4 5
4 5
4 5
4 5
4 5
3 6
3 6
3 6
3 6
3 6
3 6
3 6
3 2
3 2
3 2
3 2
3 2
3 2
3 2
2 0
2 0
2 0
2 0
2 0
2 0
2 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 2
0 2
0 2
0 2
0 2
...

input:

12012
2
6
7 8 9 10 11 12
6
6 8 9 10 11 12
6
6 7 9 10 11 12
6
6 7 8 10 11 12
6
6 7 8 9 11 12
6
6 7 8 9 10 12
6
6 7 8 9 10 11
6
7 8 9 10 11 12
6
5 8 9 10 11 12
6
5 7 9 10 11 12
6
5 7 8 10 11 12
6
5 7 8 9 11 12
6
5 7 8 9 10 12
6
5 7 8 9 10 11
6
7 8 9 10 11 12
6
4 8 9 10 11 12
6
4 7 9 10 11 12
6
4 7 8 1...

output:

10 7
10 6
10 9
6 10
6 9
6 7
9 6
10 7
10 5
11 9
5 10
5 9
5 7
9 5
10 7
10 4
10 11
4 10
4 9
8 10
9 4
10 7
10 3
9 7
3 10
3 9
12 10
9 3
10 7
10 2
7 10
2 10
2 9
2 7
9 2
10 7
10 1
11 10
1 10
1 9
1 7
9 1
10 7
10 0
7 9
0 10
0 9
0 7
9 0
10 6
10 5
11 5
6 5
5 6
11 10
10 6
10 4
9 12
4 6
8 9
10 6
10 3
9 6
10 12
9...

input:

12012
3
6
0 3 10 7
6
0 3 10 6
6
0 3 10 9
6
0 3 6 10
6
0 3 6 9
6
0 3 6 7
6
0 3 9 6
6
1 4 10 7
6
1 4 10 5
6
1 4 11 9
6
1 4 5 10
6
1 4 5 9
6
1 4 5 7
6
1 4 9 5
6
1 5 10 7
6
1 5 10 4
6
1 5 10 11
6
1 5 4 10
6
1 5 4 9
6
1 5 8 10
6
1 5 9 4
6
0 6 10 7
6
0 6 10 3
6
0 6 9 7
6
0 6 3 10
6
0 6 3 9
6
0 6 12 10
6
0...

output:

6
7
8
9
10
11
12
5
7
8
9
10
11
12
4
7
8
9
10
11
12
3
7
8
9
10
11
12
1
0
7
3
8
6
2
0
3
9
2
6
5
8
3
9
6
12
11
0
10
4
5
6
11
0
10
4
11
10
1
5
3
6
8
12
11
0
10
2
6
8
3
8
6
2
1
6
8
2
6
5
8
0
6
8
8
5
4
4
5
8
9
4
1
5
3
5
8
9
11
0
10
2
5
8
9
8
6
2
1
5
8
9
6
5
8
0
5
8
9
0
3
11
3
4
8
9
11
0
10
2
4
8
9
8
6
2
1...

result:

wrong answer the card you returned is 1, but expected 2 (test case 29)

Subtask #2:

score: 0
Skipped

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 21ms = 0ms + 21ms
memory: 0kb,3636kb

input:

6525
1
6
10 1 11 3 12 6
6
1 7 10 12 5 6
6
0 10 12 7 9 8
6
12 1 8 4 7 11
6
11 8 9 4 10 6
6
0 7 2 3 4 5
6
0 8 3 10 11 6
6
0 1 2 4 7 6
6
0 1 11 9 5 6
6
7 1 12 8 6 5
7
0 1 13 10 12 5 6
7
0 14 2 3 4 12 6
7
11 1 3 8 12 6 13
7
0 1 2 3 13 5 14
7
11 9 10 8 4 14 7
7
0 8 14 3 4 13 11
7
0 10 2 14 8 5 6
7
0 13 2...

output:

3 10
1 5
10 9
1 4
8 9
0 2
0 10
0 1
0 6
1 12
0 10
0 6
6 8
5 0
10 14
0 14
0 10
5 2
1 6
9 2
13 5
16 5
0 1
0 16
15 0
8 1
0 5
5 16
9 12
0 9
12 15
16 5
0 6
12 10
0 5
13 5
7 5
0 1
9 0
1 0
9 2
2 1
13 12
10 0
15 6
0 10
6 10
1 5
5 1
16 15
9 16
4 20
18 14
14 9
21 9
20 0
14 2
15 0
5 13
21 9
10 20
10 0
18 17
3 1...

input:

6525
2
6
0 2 4 5 8 9
6
2 3 4 8 9 11
6
1 2 3 4 5 11
6
0 3 5 6 9 10
6
0 1 3 5 7 12
6
1 6 8 10 11 12
6
2 4 5 7 9 12
6
5 8 9 10 11 12
6
3 4 7 8 10 12
6
0 2 3 4 9 11
7
2 3 4 7 8 9 11
7
1 5 7 8 9 10 13
7
0 4 5 7 9 10 14
7
4 6 7 8 9 10 11
7
0 1 2 3 5 6 13
7
1 2 5 7 9 10 12
7
1 3 4 9 11 12 13
7
1 3 4 6 10 1...

output:

0 5
9 8
5 1
9 0
12 0
8 10
2 5
10 5
7 10
9 0
2 3
9 5
0 10
10 4
2 6
5 2
4 9
3 1
12 9
0 16
9 3
2 6
5 1
10 4
0 5
14 2
9 1
0 16
14 3
0 9
2 18
1 15
1 15
9 7
1 0
9 12
8 9
6 4
4 14
15 6
14 5
4 6
1 9
1 0
8 15
9 4
2 9
11 9
9 0
20 5
1 11
0 12
11 20
18 1
12 2
6 18
18 3
0 10
6 0
3 1
5 9
2 1
7 6
15 4
14 4
9 1
4 9...

input:

6525
3
6
3 10 0 5
6
1 5 9 8
6
10 9 5 1
6
1 4 9 0
6
8 9 12 0
6
0 2 8 10
6
0 10 2 5
6
0 1 10 5
6
0 6 7 10
6
1 12 9 0
7
0 10 2 3
7
0 6 9 5
7
6 8 0 10
7
5 0 10 4
7
10 14 2 6
7
0 14 5 2
7
0 10 4 9
7
5 2 3 1
7
1 6 12 9
7
9 2 0 16
8
13 5 9 3
8
16 5 2 6
8
0 1 5 1
8
0 16 10 4
8
15 0 0 5
8
8 1 14 2
8
0 5 9 1
...

output:

7
0
6
2
2
9
1
3
2
10
14
11
2
12
12
6
7
8
0
3
6
4
9
13
8
2
1
13
4
15
1
0
10
14
5
10
17
0
9
9
17
17
15
16
10
13
19
16
16
13
22
5
15
20
5
7
0
12
17
7
13
2
16
0
11
0
17
15
17
15
22
12
0
12
5
0
9
1
8
20
10
1
20
12
9
5
8
11
13
14
18
16
4
2
21
10
21
1
17
5
13
12
11
21
5
13
10
21
11
11
2
4
13
2
12
21
9
5
1
...

result:

wrong answer the card you returned is 3, but expected 0 (test case 20)

Subtask #4:

score: 0
Skipped