Submission #19508


Source Code Expand

Copy
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

const int MAXN = 32;
const int MAXM = 3628800;

int a[MAXN], b[MAXN];

int main() {
    int n, m, k, c;
    int p[MAXN];

    scanf("%d%d%d", &n, &m, &k);
    for (int i = 0; i < m; ++i) {
        scanf("%d%d", &a[i], &b[i]);
    }

    c = 0;
    for (int i = 0; i < MAXM; ++i) {
        for (int j = 0; j < n; ++j) {
            p[j] = j;
        }
        for (int j = 0; j < k; ++j) {
            int x = rand() % n;
            int y = rand() % (n - 1);
            if (y >= x) {
                ++y;
            }
            swap(p[x], p[y]);
        }
        bool flag = true;
        for (int j = 0; j < m; ++j) {
            int d = abs(p[a[j]] - p[b[j]]);
            flag &= d != 1 && d != n - 1;
        }
        if (flag) {
            ++c;
        }
    }

    printf("%lf\n", 1.0 * c / MAXM);

    return 0;
}

Submission Info

Submission Time
Task D - シャッフル席替え
User watashi
Language C++11 (GCC 4.8.1)
Score 100
Code Size 977 Byte
Status AC
Exec Time 3007 ms
Memory 760 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:17:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:19:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

Judge Result

Set Name all
Score / Max Score 100 / 100
Status
AC × 71
Set Name Test Cases
all 00_mini_01.txt, 00_mini_02.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_rnd_11_01.txt, 01_rnd_11_02.txt, 01_rnd_11_03.txt, 01_rnd_11_04.txt, 01_rnd_11_05.txt, 01_rnd_11_06.txt, 01_rnd_11_07.txt, 01_rnd_11_08.txt, 01_rnd_11_09.txt, 01_rnd_11_10.txt, 01_rnd_11_11.txt, 01_rnd_11_12.txt, 01_rnd_11_13.txt, 01_rnd_11_14.txt, 01_rnd_11_15.txt, 01_rnd_11_16.txt, 01_rnd_11_17.txt, 01_rnd_11_18.txt, 01_rnd_11_19.txt, 01_rnd_11_20.txt, 01_rnd_11_21.txt, 01_rnd_11_22.txt, 01_rnd_7_01.txt, 01_rnd_7_02.txt, 01_rnd_7_03.txt, 01_rnd_7_04.txt, 01_rnd_7_05.txt, 01_rnd_7_06.txt, 01_rnd_7_07.txt, 01_rnd_7_08.txt, 01_rnd_7_09.txt, 01_rnd_7_10.txt, 01_rnd_7_11.txt, 01_rnd_7_12.txt, 01_rnd_7_13.txt, 01_rnd_7_14.txt, 01_rnd_7_15.txt, 01_rnd_7_16.txt, 01_rnd_7_17.txt, 01_rnd_7_18.txt, 01_rnd_7_19.txt, 01_rnd_7_20.txt, 01_rnd_7_21.txt, 01_rnd_7_22.txt, 01_rnd_8_01.txt, 01_rnd_8_02.txt, 01_rnd_8_03.txt, 01_rnd_8_04.txt, 01_rnd_8_05.txt, 01_rnd_8_06.txt, 01_rnd_8_07.txt, 01_rnd_8_08.txt, 01_rnd_8_09.txt, 01_rnd_8_10.txt, 01_rnd_8_11.txt, 01_rnd_8_12.txt, 01_rnd_8_13.txt, 01_rnd_8_14.txt, 01_rnd_8_15.txt, 01_rnd_8_16.txt, 01_rnd_8_17.txt, 01_rnd_8_18.txt, 01_rnd_8_19.txt, 01_rnd_8_20.txt, 01_rnd_8_21.txt, 01_rnd_8_22.txt
Case Name Status Exec Time Memory
00_mini_01.txt AC 2329 ms 660 KB
00_mini_02.txt AC 2417 ms 664 KB
00_sample_01.txt AC 245 ms 672 KB
00_sample_02.txt AC 2519 ms 664 KB
00_sample_03.txt AC 376 ms 644 KB
01_rnd_11_01.txt AC 2347 ms 664 KB
01_rnd_11_02.txt AC 2406 ms 660 KB
01_rnd_11_03.txt AC 2439 ms 660 KB
01_rnd_11_04.txt AC 2481 ms 752 KB
01_rnd_11_05.txt AC 2500 ms 660 KB
01_rnd_11_06.txt AC 2886 ms 660 KB
01_rnd_11_07.txt AC 2824 ms 676 KB
01_rnd_11_08.txt AC 2592 ms 672 KB
01_rnd_11_09.txt AC 2624 ms 664 KB
01_rnd_11_10.txt AC 3007 ms 664 KB
01_rnd_11_11.txt AC 2747 ms 672 KB
01_rnd_11_12.txt AC 2002 ms 640 KB
01_rnd_11_13.txt AC 76 ms 656 KB
01_rnd_11_14.txt AC 394 ms 680 KB
01_rnd_11_15.txt AC 2394 ms 716 KB
01_rnd_11_16.txt AC 1530 ms 660 KB
01_rnd_11_17.txt AC 940 ms 660 KB
01_rnd_11_18.txt AC 1763 ms 660 KB
01_rnd_11_19.txt AC 2359 ms 664 KB
01_rnd_11_20.txt AC 2398 ms 664 KB
01_rnd_11_21.txt AC 1624 ms 656 KB
01_rnd_11_22.txt AC 1078 ms 680 KB
01_rnd_7_01.txt AC 2342 ms 664 KB
01_rnd_7_02.txt AC 2416 ms 660 KB
01_rnd_7_03.txt AC 2515 ms 676 KB
01_rnd_7_04.txt AC 2488 ms 652 KB
01_rnd_7_05.txt AC 2508 ms 668 KB
01_rnd_7_06.txt AC 2542 ms 660 KB
01_rnd_7_07.txt AC 2641 ms 672 KB
01_rnd_7_08.txt AC 2603 ms 760 KB
01_rnd_7_09.txt AC 2756 ms 656 KB
01_rnd_7_10.txt AC 2669 ms 664 KB
01_rnd_7_11.txt AC 2709 ms 660 KB
01_rnd_7_12.txt AC 1311 ms 660 KB
01_rnd_7_13.txt AC 2311 ms 656 KB
01_rnd_7_14.txt AC 1526 ms 656 KB
01_rnd_7_15.txt AC 1331 ms 660 KB
01_rnd_7_16.txt AC 2285 ms 660 KB
01_rnd_7_17.txt AC 1107 ms 668 KB
01_rnd_7_18.txt AC 1536 ms 664 KB
01_rnd_7_19.txt AC 761 ms 640 KB
01_rnd_7_20.txt AC 1048 ms 712 KB
01_rnd_7_21.txt AC 1644 ms 660 KB
01_rnd_7_22.txt AC 746 ms 664 KB
01_rnd_8_01.txt AC 2409 ms 684 KB
01_rnd_8_02.txt AC 2401 ms 660 KB
01_rnd_8_03.txt AC 2435 ms 656 KB
01_rnd_8_04.txt AC 2476 ms 660 KB
01_rnd_8_05.txt AC 2505 ms 692 KB
01_rnd_8_06.txt AC 2535 ms 672 KB
01_rnd_8_07.txt AC 2565 ms 668 KB
01_rnd_8_08.txt AC 2586 ms 656 KB
01_rnd_8_09.txt AC 2697 ms 664 KB
01_rnd_8_10.txt AC 2669 ms 672 KB
01_rnd_8_11.txt AC 2698 ms 668 KB
01_rnd_8_12.txt AC 1541 ms 660 KB
01_rnd_8_13.txt AC 232 ms 664 KB
01_rnd_8_14.txt AC 1636 ms 656 KB
01_rnd_8_15.txt AC 1243 ms 656 KB
01_rnd_8_16.txt AC 1045 ms 660 KB
01_rnd_8_17.txt AC 2306 ms 664 KB
01_rnd_8_18.txt AC 614 ms 664 KB
01_rnd_8_19.txt AC 1327 ms 656 KB
01_rnd_8_20.txt AC 1830 ms 648 KB
01_rnd_8_21.txt AC 705 ms 676 KB
01_rnd_8_22.txt AC 2466 ms 664 KB