QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#630184 | #8830. Breaking Bad | RainingLove | WA | 73ms | 3864kb | C++23 | 1.6kb | 2024-10-11 16:54:33 | 2024-10-11 16:54:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n;
int a[1003][1003];
vector<pair<int,int>> b[5];
int vis[5];
void solve() {
cin>>n;
for(int i=1;i<=n;i++) {
map<int,int> mp;
for(int j=1;j<=n;j++) {
cin>>a[i][j];
b[a[i][j]].push_back({i,j});
}
}
set<int> row,col;
while(row.size()<min(n,7) || col.size()<min(n,7)) {
int f=0;
for(int i=0;i<5;i++) {
while(!b[i].empty() &&(row.find(b[i].back().first)!=row.end() && col.find(b[i].back().second)!=col.end())) b[i].pop_back();
if(b[i].empty()) continue;
f=1;
row.insert(b[i].back().first);
col.insert(b[i].back().second);
}
if(!f)break;
}
vector<int> R(row.begin(),row.end());
vector<int> C(col.begin(),col.end());
int base=0;
for(int i=1;i<=n;i++) {
if(col.find(i)==col.end()) {
for(int j=1;j<=n;j++) {
if(row.find(j)==row.end()) {
base=(base+a[j][i])%5;
}
}
break;
}
}
sort(C.begin(),C.end());
do {
int sum=0;
for(int i=0;i<R.size();i++) {
sum=(sum+a[R[i]][C[i]])%5;
}
vis[(base+sum)%5]=1;
} while(next_permutation(C.begin(),C.end()));
for(int i=0;i<5;i++) {
if(vis[i]) cout<<"Y";
else cout<<"N";
}
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int t=1;
// cin>>t;
while(t--)
solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3644kb
input:
2 0 4 4 0
output:
YNNYN
result:
ok "YNNYN"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
2 1 1 1 1
output:
NNYNN
result:
ok "NNYNN"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3572kb
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: 3640kb
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: 0
Accepted
time: 73ms
memory: 3864kb
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:
NYNNY
result:
ok "NYNNY"
Test #6:
score: -100
Wrong Answer
time: 52ms
memory: 3672kb
input:
10 4 4 4 1 3 4 1 4 3 0 3 3 3 0 2 3 0 3 2 4 3 3 3 0 2 3 0 3 2 4 4 4 4 1 3 4 1 4 3 0 2 2 2 4 1 2 4 2 1 3 2 2 2 4 1 3 4 2 1 3 4 4 4 1 3 4 1 4 3 0 3 3 3 0 2 3 0 3 2 4 2 2 2 4 1 2 4 2 1 3 4 4 4 1 3 4 1 1 3 0
output:
YYYYY
result:
wrong answer 1st words differ - expected: 'YYYNY', found: 'YYYYY'