結果

問題 No.3235 巡回減算
ユーザー t98slider
提出日時 2025-08-15 22:15:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 276 ms / 10,000 ms
コード長 668 bytes
コンパイル時間 1,842 ms
コンパイル使用メモリ 197,664 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-15 22:15:32
合計ジャッジ時間 7,724 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<string> A(8);
    for(auto &&str : A) cin >> str;
    string str(8, '0');
    constexpr int mx = 2097152;
    for(int S = 0; S < mx; S++){
        fill(str.begin(), str.end(), '0');
        for(int j = 1, sh, tmp = S; j < 8; j++, tmp /= 8){
            sh = tmp % 8;
            for(int k = 0; k < 8; k++){
                str[k] = min(str[k] + (int)(A[j][(k + sh) % 8] - '0'), (int)':');
            }
        }
        if(str == A[0]){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}
0