Submission #59212480
Source Code Expand
// Problem: A - Underclued
// URL: https://atcoder.jp/contests/arc186/tasks/arc186_a
// Writer: WRuperD
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int mininf = 1e9 + 7;
#define int long long
#define pb emplace_back
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
inline void write(int x){if(x<0){x=~(x-1);putchar('-');}if(x>9)write(x/10);putchar(x%10+'0');}
#define put() putchar(' ')
#define endl puts("")
const int MAX = 55;
int f[MAX][MAX][MAX * MAX];
void solve(){
int n = read(), q = read();
for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++){
if(min(i, j) >= 2) f[i][j][0] = 1;
f[i][j][i * j] =1;
}
// for(int i = 2; i <= n; i++) for(int j = 2; j <= n; j++) if(i == j) f[i][j][1]
for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) if(i == 0 or j == 0) f[i][j][0] = 1;
// f[0][0][0] = 1;
// f[1][1][0] = 0;
// f[1][1][1] = 1;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
for(int k = 0; k <= n * n; k++){
if(k - j >= 0) f[i][j][k] |= f[i - 1][j][k - j];
if(k - i >= 0) f[i][j][k] |= f[i][j - 1][k - i];
// f[i][j][k] |= f[i - 1][j][k];
// f[i][j][k] |= f[i][j - 1][k];
}
}
}
// write(f[1][1][0]), endl;
// write(f[2][1][1]), endl;
// write(f[n][1][n]), endl;
// write(f[1][1][1]), end
// // write(f[2][2][2]), endl;
// write(f[3][4][4]), endl;
// for(int i = 0; i <= n * n; i++){
// if(f[n][n][i]){
// write(i), put();
// }
// }
// endl;
// for(int i = 0; i <= n * n; i++) write(f[n][n][i]), put();
// endl;
while(q--){
int x = read();
if(f[n][n][x]) puts("Yes");
else puts("No");
}
}
signed main(){
int t = 1;
while(t--) solve();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Underclued |
| User | WRuperD |
| Language | C++ 20 (gcc 12.2) |
| Score | 0 |
| Code Size | 1922 Byte |
| Status | WA |
| Exec Time | 5 ms |
| Memory | 13592 KiB |
Judge Result
| Set Name | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 900 | ||||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt |
| All | 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, sample_01.txt, sample_02.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 02.txt | AC | 1 ms | 3472 KiB |
| 03.txt | AC | 1 ms | 3528 KiB |
| 04.txt | AC | 1 ms | 3532 KiB |
| 05.txt | WA | 1 ms | 3516 KiB |
| 06.txt | WA | 1 ms | 3660 KiB |
| 07.txt | WA | 1 ms | 3700 KiB |
| 08.txt | WA | 1 ms | 3784 KiB |
| 09.txt | WA | 1 ms | 3816 KiB |
| 10.txt | WA | 1 ms | 4016 KiB |
| 11.txt | WA | 1 ms | 4152 KiB |
| 12.txt | WA | 1 ms | 4268 KiB |
| 13.txt | WA | 1 ms | 4496 KiB |
| 14.txt | WA | 1 ms | 4680 KiB |
| 15.txt | WA | 1 ms | 4944 KiB |
| 16.txt | WA | 1 ms | 5068 KiB |
| 17.txt | WA | 1 ms | 5484 KiB |
| 18.txt | WA | 1 ms | 5804 KiB |
| 19.txt | WA | 2 ms | 6048 KiB |
| 20.txt | WA | 2 ms | 6476 KiB |
| 21.txt | WA | 2 ms | 7032 KiB |
| 22.txt | WA | 2 ms | 7380 KiB |
| 23.txt | WA | 2 ms | 7984 KiB |
| 24.txt | WA | 3 ms | 8580 KiB |
| 25.txt | WA | 3 ms | 9188 KiB |
| 26.txt | WA | 3 ms | 9924 KiB |
| 27.txt | WA | 4 ms | 10728 KiB |
| 28.txt | WA | 4 ms | 11608 KiB |
| 29.txt | WA | 5 ms | 12600 KiB |
| 30.txt | WA | 5 ms | 13592 KiB |
| sample_01.txt | AC | 1 ms | 3516 KiB |
| sample_02.txt | WA | 4 ms | 12600 KiB |