Submission #45383327


Source Code Expand

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;
const int N = 200200, M = 12, L = 4;
#define inf 0x3f3f3f3f

int a, b;
int c[L][L], p[M], vis[L][L];

int B[L][L] = {{0,0,0,0},
               {0,1,0,1},
               {0,0,1,0},
               {0,1,0,1}};

vector <pair<int ,int>> v1, v2, v3, v4;

int main(){
    // freopen("the.in", "r", stdin);
    // freopen("the.out", "w", stdout);
    for (int i = 1; i <= 3; i ++)
        for (int j = 1; j <= 3; j ++)
            cin >> c[i][j];
    for (int i = 1; i <= 9; i ++) p[i] = i;
    // for (int i = 1; i <= 9; i ++) {
    //     int x = ((p[i] + 2) / 3);
    //     cout << (p[i] + 2)/ 3 << '\n';
    //     int y = (p[i] % 3) + (p[i] % 3 == 0) * 3;
    //     cout << x << ' ' << y << '\n';
    // }
    // cout << (7 + 2)/ 3 << '\n';
    do{
        int flag = 0;
        memset(vis, 0, sizeof vis);
        for (int i = 1; i <= 9; i ++) { 
            int x = ((p[i] + 2) / 3);
            int y = (p[i] % 3) + (p[i] % 3 == 0) * 3;
            vis[x][y] = 1;
            v1.clear();v2.clear();
            v3.clear();v4.clear();
            for (int j = 1; j <= 3; j ++)
                for (int k = 1; k <= 3; k ++) {
                    if (j == x && k == y) continue;
                    if (j == x) v1.push_back({j, k});
                    if (k == y) v2.push_back({j, k});
                    if (!B[x][y]) continue;
                    if ((x + y) == (j + k))
                        v3.push_back({j, k});
                    if ((x - y) == (j - k))
                        v4.push_back({j, k});
                }
            if (vis[v1[0].first][v1[0].second]&&vis[v1[1].first][v1[1].second]&&c[v1[0].first][v1[0].second]==c[v1[1].first][v1[1].second]&&c[x][y]!=c[v1[1].first][v1[1].second]) flag = 1;
            if (vis[v2[0].first][v2[0].second]&&vis[v2[1].first][v2[1].second]&&c[v2[0].first][v2[0].second]==c[v2[1].first][v2[1].second]&&c[x][y]!=c[v2[1].first][v2[1].second]) flag = 1;
            if (!B[x][y]) continue;
            if (v3.size() && vis[v3[0].first][v3[0].second]&&vis[v3[1].first][v3[1].second]&&c[v3[0].first][v3[0].second]==c[v3[1].first][v3[1].second]&&c[x][y]!=c[v3[1].first][v3[1].second]) flag = 1;
            if (v4.size() && vis[v4[0].first][v4[0].second]&&vis[v4[1].first][v4[1].second]&&c[v4[0].first][v4[0].second]==c[v4[1].first][v4[1].second]&&c[x][y]!=c[v4[1].first][v4[1].second]) flag = 1;
        }
        if (flag) a ++;
        b ++;
    }
    while(next_permutation(p + 1, p + 9 + 1));
    double ans = 1.0 * (b - a) / b;
    printf("%.11lf\n", ans);
    return 0;
}

Submission Info

Submission Time
Task C - False Hope
User TKXZ133
Language C++ 20 (gcc 12.2)
Score 300
Code Size 2730 Byte
Status AC
Exec Time 94 ms
Memory 3836 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
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_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 92 ms 3684 KiB
00_sample_01.txt AC 93 ms 3812 KiB
00_sample_02.txt AC 93 ms 3748 KiB
01_random_03.txt AC 92 ms 3628 KiB
01_random_04.txt AC 93 ms 3628 KiB
01_random_05.txt AC 92 ms 3820 KiB
01_random_06.txt AC 92 ms 3812 KiB
01_random_07.txt AC 94 ms 3836 KiB
01_random_08.txt AC 92 ms 3700 KiB
01_random_09.txt AC 94 ms 3684 KiB
01_random_10.txt AC 92 ms 3692 KiB
01_random_11.txt AC 92 ms 3720 KiB
01_random_12.txt AC 92 ms 3832 KiB
01_random_13.txt AC 93 ms 3676 KiB
01_random_14.txt AC 93 ms 3660 KiB