QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#630334#8830. Breaking BadRainingLoveWA 0ms3632kbC++231.7kb2024-10-11 17:58:372024-10-11 17:58:37

Judging History

你现在查看的是最新测评结果

  • [2024-10-11 17:58:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3632kb
  • [2024-10-11 17:58:37]
  • 提交

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++) {
        for(int j=1;j<=n;j++) {
            cin>>a[i][j];
            b[a[i][j]].push_back({i,j});
        }
    }

    set<int> row,col;
    bitset<1002> vr,vc;
    while(row.size()<min(n,8) || col.size()<min(n,8)) {
        int f=0;
        for(int i=0;i<5;i++) {
            while(!b[i].empty() &&(vr[b[i].back().first] && vc[b[i].back().second])) b[i].pop_back();
            if(b[i].empty()) continue;
            f=1;
            row.insert(b[i].back().first);
            col.insert(b[i].back().second);
            vr[b[i].back().first]=1;
            vc[b[i].back().second]=1;
        }
        if(!f)break;
    }

    vector<int> R(row.begin(),row.end());
    vector<int> C(col.begin(),col.end());
    int base=0;
    int i=1,j=1;
    for(;i<=n;i++) {
        if(!vc[i]) {
            for(;j<=n;j++) {
                if(!vr[j]) {
                    base=(base+a[j][i])%5;
                    break;
                }
            }
            break;
        }
    }

    int t=5000000;
    do {
        random_shuffle(R.begin(),R.end());
        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: 0
Wrong Answer
time: 0ms
memory: 3632kb

input:

2
0 4
4 0

output:

YNNNN

result:

wrong answer 1st words differ - expected: 'YNNYN', found: 'YNNNN'