結果
| 問題 |
No.3235 巡回減算
|
| コンテスト | |
| ユーザー |
houren
|
| 提出日時 | 2025-08-16 00:44:03 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,080 bytes |
| コンパイル時間 | 4,551 ms |
| コンパイル使用メモリ | 314,916 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-08-16 00:44:09 |
| 合計ジャッジ時間 | 5,352 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 13 |
ソースコード
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2,tune=native")
#define rep(i, n) for(int i = 0; i < n; ++i)
#include <bits/stdc++.h>
using namespace std;
int f(int a){
int res = 0;
while(a) res += a%10, a/=10;
return res;
}
int x, y[7][8], p[1<<9], q[1<<12];
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin >> x; rep(i,7) cin >> y[i][0];
int cnt = f(x); rep(i,7) cnt -= f(y[i][0]);
if(cnt){
cout << "No\n";
return 0;
}
rep(i,7)rep(j,7) y[i][j+1] = y[i][j]%10*10000000 + y[i][j]/10;
bool ans = false;
rep(a,8)rep(b,8)rep(c,8) p[a+(b<<3)+(c<<6)] = y[0][a]+y[1][b]+y[2][c];
rep(a,8)rep(b,8)rep(c,8)rep(d,8) q[a+(b<<3)+(c<<6)+(d<<9)] = y[3][a]+y[4][b]+y[5][c]+y[6][d];
sort(p,p+(1<<9));
sort(q,q+(1<<12));
for(int i=0,j=0;i<(1<<9)&&j<(1<<12);++i){
while(j<(1<<12) && x-p[i]>q[j]) ++j;
if(j<(1<<12) && x-p[i]==q[j]){
ans = true;
break;
}
}
cout << (ans?"Yes\n":"No\n");
return 0;
}
houren