結果

問題 No.3235 巡回減算
ユーザー yantaro
提出日時 2025-09-14 17:23:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 2,222 bytes
コンパイル時間 1,820 ms
コンパイル使用メモリ 198,704 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-14 17:23:33
合計ジャッジ時間 16,133 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 TLE * 1 -- * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;

using ll = long long;
using ld = long double;

//using mint = modint; //mint::set_mod(M);
//using mint = modint998244353;
//using mint = modint1000000007;

template<class T> using pq = priority_queue<T>; //大きい順
template<class T> using pq_g = priority_queue<T, vector<T>, greater<T>>; //小さい順

#define vec_unique(v) v.erase(unique(v.begin(), v.end()), v.end()) //重複削除
#define vec_iota(v) iota(v.begin(), v.end(), 0) //0, 1, 2, 3, ..., n - 1にセット
#define concat(a, b) a.insert(a.end(), b.begin(), b.end())
#define debug(x) cerr << #x << " = " << x << endl

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
//int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

#define INF 2e18
#define INF2 2e9

#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
    string s;
    cin >> s;
    vector<string> t(7);
    for(int i = 0; i < 7; i++) {
        cin >> t[i];
    }
    string u = "00000000";

    auto update = [&](int i, int j) {
        for(int k = 0; k < 8; k++) {
            u[(j + k) % 8] += t[i][k] - '0';
        }
    };

    rep(a2, 8) {
        rep(a3, 8) {
            rep(a4, 8) {
                rep(a5, 8) {
                    rep(a6, 8) {
                        rep(a7, 8) {
                            rep(a8, 8) {
                                update(0, a2);
                                update(1, a3);
                                update(2, a4);
                                update(3, a5);
                                update(4, a6);
                                update(5, a7);
                                update(6, a8);
                                debug(u);
                                if(s == u) {
                                    cout << "Yes" << endl;
                                    return 0;
                                }
                                u = "00000000";
                            }
                        }
                    }
                }
            }
        }
    }

    cout << "No" << endl;
    //cout << fixed << setprecision(15) << << endl;
    return 0;
}
0