QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#583870 | #8830. Breaking Bad | yanchengzhi | WA | 0ms | 3760kb | C++20 | 4.4kb | 2024-09-22 23:19:10 | 2024-09-22 23:19:11 |
Judging History
answer
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 1005;
int n, tot, a[4][maxn], ans[5], delta;
void init() {
cin >> n;
vector<int> cnt1(n + 1), cnt2(n + 1);
vector<vector<int>> B(n + 1, vector<int>(n + 1));
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
cin >> B[i][j];
}
}
for(int i = 1; i <= n; i++) {
int mn = 6;
for(int j = 1; j <= n; j++) {
mn = min(mn, B[i][j]);
}
for(int j = 1; j <= n; j++) {
B[i][j] -= mn;
}
delta = (delta + mn) % 5;
}
for(int j = 1; j <= n; j++) {
int mn = 6;
for(int i = 1; i <= n; i++) {
mn = min(mn, B[i][j]);
}
for(int i = 1; i <= n; i++) {
B[i][j] -= mn;
}
delta = (delta + mn) % 5;
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
if(B[i][j]) {
cnt1[i]++;
cnt2[j]++;
}
}
}
int c1 = 0, c2 = 0;
for(int i = 1; i <= n; i++) {
c1 += (cnt1[i] > 0);
c2 += (cnt2[i] > 0);
}
if(c1 >= 4 && c2 >= 4) {
cout << "YYYYY";
exit(0);
}
if(c1 > c2) {
vector<vector<int>> A(n + 1, vector<int>(n + 1));
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
A[i][j] = B[j][i];
}
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
B[i][j] = A[i][j];
}
}
}
for(int i = 1; i <= n; i++) {
bool ok = 0;
for(int j = 1; j <= n; j++) {
if(B[i][j]) {
ok = 1;
}
}
if(ok) {
tot++;
for(int j = 1; j <= n; j++) {
a[tot][j] = B[i][j];
}
}
}
}
int main() {
#ifdef yczDEBUG
freopen("1.in", "r", stdin);
freopen("b.out", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
init();
// for(int i = 1; i <= tot; i++) {
// for(int j = 1; j <= n; j++) {
// cout << a[i][j] << ' ';
// }
// cout << '\n';
// }
if(tot == 0) {
ans[0] = 1;
}
else if(tot == 1) {
for(int i = 1; i <= n; i++) {
ans[a[1][i]] = 1;
}
}
else if(tot == 2) {
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
if(i != j) {
ans[(a[1][i] + a[2][j]) % 5] = 1;
}
}
}
}
else {
int p[4] = {0, 1, 2, 3};
do {
vector<int> tong(5);
for(int j = 1; j <= n; j++) {
for(int i = 1; i < j; i++) {
tong[(a[p[1]][i] + a[p[2]][j]) % 5] = 1;
}
for(int k = j + 1; k <= n; k++) {
for(int o = 0; o < 5; o++) {
if(tong[o]) {
ans[(a[p[3]][k] + o) % 5] = 1;
}
}
}
}
}
while(next_permutation(p + 1, p + 1 + 3));
}
// cout << delta << '\n';
for(int i = 0; i < 5; i++) {
cout << (ans[(i - delta + 5) % 5] ? 'Y' : 'N');
}
// for(int i = 1; i <= 4; i++) {
// for(int j = 1; j <= 4; j++) {
// for(int k = 1; k <= 4; k++) {
// for(int o = 1; o <= 4; o++) {
// int a[4] = {i, j, k, o};
// vector<int> vis(5);
// for(int s = 0; s < (1 << 4); s++) {
// int sum = 0;
// for(int x = 0; x < 4; x++) {
// if(s >> x & 1) {
// sum = (sum + a[x]) % 5;
// }
// }
// vis[sum] = 1;
// }
// int c = 0;
// for(int x = 0; x < 5; x++) {
// c += vis[x];
// }
// if(c < 5) {
// cout << i << ' ' << j << ' ' << k << ' ' << o << '\n';
// }
// }
// }
// }
// }
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
2 0 4 4 0
output:
YNNYN
result:
ok "YNNYN"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
2 1 1 1 1
output:
NNYNN
result:
ok "NNYNN"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
4 0 0 1 0 0 1 0 1 0 0 0 0 1 1 0 0
output:
YYYYN
result:
ok "YYYYN"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
4 0 0 0 1 0 1 0 1 1 0 0 0 0 1 0 0
output:
YYYYN
result:
ok "YYYYN"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3760kb
input:
10 1 4 2 0 0 2 0 1 3 3 0 3 1 4 4 1 4 0 2 2 1 4 2 0 0 2 0 1 0 3 0 3 1 4 4 1 4 0 2 2 4 2 0 3 3 0 3 4 1 1 2 0 3 1 1 3 1 2 4 4 4 2 0 3 3 0 3 4 1 1 2 0 3 1 1 3 1 2 4 4 1 4 2 0 0 2 0 1 3 3 3 1 4 2 2 4 2 3 0 0
output:
YYYYY
result:
wrong answer 1st words differ - expected: 'NYNNY', found: 'YYYYY'