Submission #16646567


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin >> N;
vector<int> P_vec(N), Q_vec(N);
for (int i = 0; i < N; ++i)
cin >> P_vec.at(i);
for (int i = 0; i < N; ++i)
cin >> Q_vec.at(i);
vector<int> perm(N);
for (int i = 0; i < N; ++i)
perm.at(i) = i + 1;
int a = -1, b = -1;
int cnt = 0;
do {
++cnt;
if (equal(P_vec.begin(), P_vec.end(), perm.begin(), perm.end()))
a = cnt;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;

int	main()
{
    int N;
    cin >> N;
    vector<int> P_vec(N), Q_vec(N);
    for (int i = 0; i < N; ++i)
        cin >> P_vec.at(i);
    for (int i = 0; i < N; ++i)
        cin >> Q_vec.at(i);
    vector<int> perm(N);
    for (int i = 0; i < N; ++i)
        perm.at(i) = i + 1;
    int a = -1, b = -1;
    int cnt = 0;
    do {
        ++cnt;
        if (equal(P_vec.begin(), P_vec.end(), perm.begin(), perm.end()))
            a = cnt;
        if (equal(Q_vec.begin(), Q_vec.end(), perm.begin(), perm.end()))
            b = cnt;
        if (a > 0 && b > 0)
            break;
    } while (next_permutation(perm.begin(), perm.end()));
    cout << abs(a - b) << endl;
}

Submission Info

Submission Time
Task C - Count Order
User atug
Language C++ (GCC 9.2.1)
Score 300
Code Size 718 Byte
Status AC
Exec Time 7 ms
Memory 3580 KB

Judge Result

Set Name All Sample
Score / Max Score 300 / 300 0 / 0
Status
AC × 13
AC × 3
Set Name Test Cases
All sample_01.txt, sample_02.txt, sample_03.txt, testcase_0.txt, testcase_1.txt, testcase_2.txt, testcase_3.txt, testcase_4.txt, testcase_5.txt, testcase_6.txt, testcase_7.txt, testcase_8.txt, testcase_9.txt
Sample sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
sample_01.txt AC 7 ms 3576 KB
sample_02.txt AC 2 ms 3576 KB
sample_03.txt AC 2 ms 3448 KB
testcase_0.txt AC 1 ms 3580 KB
testcase_1.txt AC 2 ms 3472 KB
testcase_2.txt AC 1 ms 3444 KB
testcase_3.txt AC 2 ms 3468 KB
testcase_4.txt AC 2 ms 3460 KB
testcase_5.txt AC 2 ms 3532 KB
testcase_6.txt AC 2 ms 3472 KB
testcase_7.txt AC 3 ms 3412 KB
testcase_8.txt AC 4 ms 3524 KB
testcase_9.txt AC 4 ms 3464 KB


2025-04-08 (Tue)
05:24:21 +00:00