結果
問題 |
No.3235 巡回減算
|
ユーザー |
![]() |
提出日時 | 2025-08-15 22:13:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 330 ms / 10,000 ms |
コード長 | 820 bytes |
コンパイル時間 | 1,777 ms |
コンパイル使用メモリ | 200,780 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-08-15 22:13:26 |
合計ジャッジ時間 | 12,595 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long vector<vector<int>> A(8,vector<int>(8)); vector<int> now(8); bool ans = false; void rotate(){ vector<int> nex(8); for(int i = 0; i < 8; i++){ nex[i] = now[(i+1)%8]; } now = nex; } void dfs(int depth){ if(depth == 8){ int cnt = 0; for(int i = 0; i < 8; i++) cnt += (now[i]!=0); if(cnt == 0) ans = true; return; } vector<int> mae = now; for(int i = 0; i <= 8; i++){ for(int j = 0; j < 8; j++) now[j] -= A[depth][j]; dfs(depth+1); for(int j = 0; j < 8; j++) now[j] += A[depth][j]; rotate(); } now = mae; } signed main(){ for(int i = 0; i < 8; i++){ string S;cin>>S; for(int j = 0; j < 8; j++){ A[i][j] = S[j] - '0'; } } now = A[0]; dfs(1); ans ? cout << "Yes" << "\n" : cout << "No" << "\n"; }