結果

問題 No.2463 ストレートフラッシュ
ユーザー Manuel1024Manuel1024
提出日時 2023-11-29 00:11:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 78,696 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-29 00:11:53
合計ジャッジ時間 4,879 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 107 ms
6,676 KB
testcase_14 AC 124 ms
6,676 KB
testcase_15 AC 118 ms
6,676 KB
testcase_16 AC 126 ms
6,676 KB
testcase_17 AC 147 ms
6,676 KB
testcase_18 AC 159 ms
6,676 KB
testcase_19 AC 160 ms
6,676 KB
testcase_20 AC 160 ms
6,676 KB
testcase_21 AC 150 ms
6,676 KB
testcase_22 AC 151 ms
6,676 KB
testcase_23 AC 151 ms
6,676 KB
testcase_24 AC 151 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(n*m), c(n*m);
    for(int i = 0; i < n*m; i++){
        cin >> a[i] >> c[i];
        a[i]--; c[i]--;
    }

    vector<vector<int>> t(n, vector<int>(m));
    for(int i = 0; i < n*m; i++){
        t[a[i]][c[i]] = i;
    }

    int ans = 1 << 30;
    for(int i = 0; i+3 < n; i++){
        for(int j = 0; j < m; j++){
            vector<int> tm;
            for(int k = 0; k < 5; k++){
                tm.emplace_back(t[(i+k)%n][j]);
            }
            sort(tm.begin(), tm.end());

            int res = 0;
            for(int k = 0, l = 5; k < 5; k++){
                if(tm[k] < l) continue;
                int x = (tm[k]+(5-k)-l)/(5-k);
                res += x;
                l += x*(5-k);
            }
            ans = min(ans, res);
        }
    }
    cout << ans << endl;
    return 0;
}
0