提出 #69650642


ソースコード 拡げる

#include <bits/stdc++.h>

#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define int long long
#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int, int> PI;
typedef pair<int, pair<int, int>> PII;
static const int INF = 1010000000000000017LL;
static const double eps = 1e-12;
static const double pi = 3.14159265358979323846;
static const int dx[4] = {1, -1, 0, 0};
static const int dy[4] = {0, 0, 1, -1};
static const int ddx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
static const int ddy[8] = {0, 0, 1, -1, 1, -1, 1, -1};

template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int N;

signed main() {
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    vector<int> P(N);
    for (int i = 0; i < N; ++i) {
        P[i] = i + 1;
    }
    do {
        bool ok = true;
        for (int i = 0; i < N; ++i) {
            if (A[i] == -1) continue;
            if (A[i] != P[i]) ok = false;
        }
        if (ok) {
            cout << "Yes" << endl;
            for (int i = 0; i < N; ++i) {
                cout << P[i] << " ";
            }
            cout << endl;
            return 0;
        }
    } while (next_permutation(P.begin(), P.end()));
    cout << "No" << endl;
}

提出情報

提出日時
問題 B - Find Permutation 2
ユーザ tsuyosshi
言語 C++ 20 (gcc 12.2)
得点 200
コード長 1590 Byte
結果 AC
実行時間 39 ms
メモリ 3700 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 3
AC × 32
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_Yes_00.txt, 01_Yes_01.txt, 01_Yes_02.txt, 01_Yes_03.txt, 01_Yes_04.txt, 01_Yes_05.txt, 01_Yes_06.txt, 01_Yes_07.txt, 01_Yes_08.txt, 01_Yes_09.txt, 01_Yes_10.txt, 01_Yes_11.txt, 01_Yes_12.txt, 01_Yes_13.txt, 01_Yes_14.txt, 01_Yes_15.txt, 01_Yes_16.txt, 01_Yes_17.txt, 01_Yes_18.txt, 01_Yes_19.txt, 01_Yes_20.txt, 02_No_00.txt, 02_No_01.txt, 02_No_02.txt, 02_No_03.txt, 02_No_04.txt, 02_No_05.txt, 02_No_06.txt, 02_No_07.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3500 KiB
00_sample_01.txt AC 1 ms 3616 KiB
00_sample_02.txt AC 1 ms 3692 KiB
01_Yes_00.txt AC 1 ms 3544 KiB
01_Yes_01.txt AC 1 ms 3608 KiB
01_Yes_02.txt AC 1 ms 3488 KiB
01_Yes_03.txt AC 1 ms 3544 KiB
01_Yes_04.txt AC 1 ms 3412 KiB
01_Yes_05.txt AC 33 ms 3488 KiB
01_Yes_06.txt AC 1 ms 3696 KiB
01_Yes_07.txt AC 1 ms 3476 KiB
01_Yes_08.txt AC 4 ms 3412 KiB
01_Yes_09.txt AC 1 ms 3532 KiB
01_Yes_10.txt AC 3 ms 3544 KiB
01_Yes_11.txt AC 2 ms 3512 KiB
01_Yes_12.txt AC 1 ms 3532 KiB
01_Yes_13.txt AC 1 ms 3484 KiB
01_Yes_14.txt AC 1 ms 3504 KiB
01_Yes_15.txt AC 9 ms 3512 KiB
01_Yes_16.txt AC 15 ms 3616 KiB
01_Yes_17.txt AC 19 ms 3700 KiB
01_Yes_18.txt AC 15 ms 3508 KiB
01_Yes_19.txt AC 9 ms 3412 KiB
01_Yes_20.txt AC 35 ms 3496 KiB
02_No_00.txt AC 1 ms 3540 KiB
02_No_01.txt AC 39 ms 3532 KiB
02_No_02.txt AC 1 ms 3512 KiB
02_No_03.txt AC 1 ms 3512 KiB
02_No_04.txt AC 1 ms 3548 KiB
02_No_05.txt AC 4 ms 3412 KiB
02_No_06.txt AC 1 ms 3544 KiB
02_No_07.txt AC 4 ms 3576 KiB