結果

問題 No.3235 巡回減算
ユーザー ルビサファせだい
提出日時 2025-08-17 11:14:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,816 bytes
コンパイル時間 1,241 ms
コンパイル使用メモリ 130,408 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-17 11:14:55
合計ジャッジ時間 2,668 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <memory>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <bitset>
#include <string>
#include <list>
#include <deque>
#include <stack>
#include <limits>

#include <atcoder/fenwicktree.hpp>
#include <atcoder/segtree.hpp>
#include <atcoder/modint.hpp>
#include <atcoder/dsu.hpp>

using namespace atcoder;
using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<>>;
ll ll_min = numeric_limits<ll>::min();
ll ll_max = numeric_limits<ll>::max();
ll ALPHABET_N = 26;
using mint = modint998244353;
#define rep(i, n) for (ll i = (ll)0; i < (ll)n; i++)
#define rep_(i, k, n) for (ll i = (ll)k; i < (ll)n; i++)
#define all(a) a.begin(), a.end()

int main()
{
    vector<vector<ll>> A(8, vector<ll>(8));
    rep(i, 8) {
        rep(j, 8) {
            cin >> A[i][j];
        }
    }
    vector<ll> tgt = A[0];
    auto dfs = [&](auto &f, ll depth) -> bool {
        if (depth == 8) {
            return all_of(all(tgt), [](ll x) { return x == 0; });
        }
        bool ret = false;
        rep(shift, 8) {
            vector<ll> tmp(8);
            rep(j, 8) {
                tmp[j] = A[depth][(j + shift) % 8];
            }
            rep(j, 8) {
                tgt[j] -= tmp[j];
            }
            if (f(f, depth + 1)) {
                ret = true;
            }
            rep(j, 8) {
                tgt[j] += tmp[j];
            }
            if (ret) {
                break;
            }
        }
        return ret;
    };
    if (dfs(dfs, 0)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}
0