結果
| 問題 |
No.3235 巡回減算
|
| コンテスト | |
| ユーザー |
Today03
|
| 提出日時 | 2025-08-17 15:00:20 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5,997 ms / 10,000 ms |
| コード長 | 1,639 bytes |
| コンパイル時間 | 3,391 ms |
| コンパイル使用メモリ | 296,496 KB |
| 実行使用メモリ | 418,524 KB |
| 最終ジャッジ日時 | 2025-08-17 15:01:23 |
| 合計ジャッジ時間 | 59,617 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
template<typename T> bool chmax(T& a, T b) { return a<b ? a=b, true : false; }
template<typename T> bool chmin(T& a, T b) { return a>b ? a=b, true : false; }
using ll=long long; const int INF=1e9+10; const ll INFL=4e18;
using VI=vector<int>; using VVI=vector<VI>; using VL=vector<ll>; using VVL=vector<VL>;
using PL=pair<ll,ll>; using VP=vector<PL>; using WG=vector<vector<pair<int,ll>>>;
#ifdef LOCAL
#include "./debug.hpp"
#else
#define debug(...)
#define print_line
#endif
//----------------------------------------------------------
void solve() {
ll N=8;
VVI A(N,VI(N));
REP(i,N) {
string s; cin>>s;
REP(j,N) A[i][j]=s[j]-'0';
}
vector<set<VI>> seen(N+1);
queue<pair<int,VI>> que; que.push({1,A[0]});
while(!que.empty()) {
auto [idx,now]=que.front(); que.pop();
if(idx==N) {
auto [a,b]=minmax_element(ALL(now));
if(*a==0 && *b==0) {
puts("Yes");
return;
}
continue;
}
REP(i,N) {
now.push_back(now[0]);
now.erase(now.begin());
auto nxt=now;
REP(j,N) nxt[j]-=A[idx][j];
if(!seen[idx+1].count(nxt)) {
seen[idx+1].insert(nxt);
que.push({idx+1,nxt});
}
}
}
puts("No");
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
//cout<<fixed<<setprecision(15);
int T=1; //cin>>T;
while(T--) solve();
}
Today03