Submission #19510


Source Code Expand

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

using namespace std;

const int MAXN = 32;
const int MAXM = 1 << 20;

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 868 ms
Memory 764 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 685 ms 668 KB
00_mini_02.txt AC 708 ms 664 KB
00_sample_01.txt AC 88 ms 660 KB
00_sample_02.txt AC 737 ms 664 KB
00_sample_03.txt AC 126 ms 676 KB
01_rnd_11_01.txt AC 689 ms 660 KB
01_rnd_11_02.txt AC 706 ms 664 KB
01_rnd_11_03.txt AC 718 ms 664 KB
01_rnd_11_04.txt AC 769 ms 640 KB
01_rnd_11_05.txt AC 754 ms 664 KB
01_rnd_11_06.txt AC 746 ms 668 KB
01_rnd_11_07.txt AC 751 ms 660 KB
01_rnd_11_08.txt AC 759 ms 660 KB
01_rnd_11_09.txt AC 868 ms 660 KB
01_rnd_11_10.txt AC 780 ms 744 KB
01_rnd_11_11.txt AC 787 ms 664 KB
01_rnd_11_12.txt AC 638 ms 664 KB
01_rnd_11_13.txt AC 35 ms 668 KB
01_rnd_11_14.txt AC 125 ms 676 KB
01_rnd_11_15.txt AC 696 ms 760 KB
01_rnd_11_16.txt AC 442 ms 664 KB
01_rnd_11_17.txt AC 284 ms 664 KB
01_rnd_11_18.txt AC 529 ms 716 KB
01_rnd_11_19.txt AC 722 ms 668 KB
01_rnd_11_20.txt AC 703 ms 664 KB
01_rnd_11_21.txt AC 481 ms 656 KB
01_rnd_11_22.txt AC 327 ms 764 KB
01_rnd_7_01.txt AC 685 ms 688 KB
01_rnd_7_02.txt AC 708 ms 668 KB
01_rnd_7_03.txt AC 718 ms 688 KB
01_rnd_7_04.txt AC 729 ms 660 KB
01_rnd_7_05.txt AC 738 ms 664 KB
01_rnd_7_06.txt AC 744 ms 664 KB
01_rnd_7_07.txt AC 753 ms 684 KB
01_rnd_7_08.txt AC 759 ms 668 KB
01_rnd_7_09.txt AC 773 ms 684 KB
01_rnd_7_10.txt AC 783 ms 668 KB
01_rnd_7_11.txt AC 794 ms 664 KB
01_rnd_7_12.txt AC 392 ms 660 KB
01_rnd_7_13.txt AC 723 ms 668 KB
01_rnd_7_14.txt AC 477 ms 660 KB
01_rnd_7_15.txt AC 400 ms 664 KB
01_rnd_7_16.txt AC 672 ms 652 KB
01_rnd_7_17.txt AC 316 ms 668 KB
01_rnd_7_18.txt AC 456 ms 660 KB
01_rnd_7_19.txt AC 233 ms 656 KB
01_rnd_7_20.txt AC 310 ms 672 KB
01_rnd_7_21.txt AC 521 ms 672 KB
01_rnd_7_22.txt AC 228 ms 664 KB
01_rnd_8_01.txt AC 688 ms 664 KB
01_rnd_8_02.txt AC 709 ms 660 KB
01_rnd_8_03.txt AC 718 ms 668 KB
01_rnd_8_04.txt AC 756 ms 684 KB
01_rnd_8_05.txt AC 764 ms 664 KB
01_rnd_8_06.txt AC 744 ms 664 KB
01_rnd_8_07.txt AC 753 ms 664 KB
01_rnd_8_08.txt AC 762 ms 664 KB
01_rnd_8_09.txt AC 771 ms 664 KB
01_rnd_8_10.txt AC 781 ms 672 KB
01_rnd_8_11.txt AC 789 ms 668 KB
01_rnd_8_12.txt AC 456 ms 672 KB
01_rnd_8_13.txt AC 80 ms 664 KB
01_rnd_8_14.txt AC 484 ms 660 KB
01_rnd_8_15.txt AC 380 ms 664 KB
01_rnd_8_16.txt AC 306 ms 664 KB
01_rnd_8_17.txt AC 692 ms 672 KB
01_rnd_8_18.txt AC 190 ms 668 KB
01_rnd_8_19.txt AC 395 ms 664 KB
01_rnd_8_20.txt AC 561 ms 660 KB
01_rnd_8_21.txt AC 218 ms 680 KB
01_rnd_8_22.txt AC 725 ms 664 KB