QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#778615#9226. Game of GeniusesArkhellWA 2ms3640kbC++175.9kb2024-11-24 15:29:022024-11-24 15:29:03

Judging History

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

  • [2024-11-24 15:29:03]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3640kb
  • [2024-11-24 15:29:02]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=100;
int g[N][N];
int n;
int r[N];
int c[N];
int visr[N];
int visc[N];
bool cmp(int a,int b){
    return a>b;
}
vector<int> tt;
void solve(){
    cin>>n;
    tt.push_back(0);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>g[i][j];
            tt.push_back(g[i][j]);
            r[i]=1e18;
            c[j]=-1e18;
        }
    }
    sort(tt.begin(),tt.end());
   

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            r[i]=min(r[i],g[i][j]);
        }
    }
    for(int i1=1;i1<=(n-1)*2;i1++){
        if(i1&1){
            int flag=-1;
            vector<int>v;
            for(int i=1;i<=n;i++){
                if(visr[i]){
                    continue;
                }
                if(flag==-1){
                    flag=i;
                    for(int j=1;j<=n;j++){
                        if(visc[j]){
                            continue;
                        }
                        v.push_back(g[i][j]);
                    }
                    sort(v.begin(),v.end(),cmp);
                }
                else if(r[flag]==r[i]){
                    vector<int>tmp;
                    for(int j=1;j<=n;j++){
                        if(visc[j]){
                            continue;
                        }
                        tmp.push_back(g[i][j]);
                    }
                    sort(tmp.begin(),tmp.end(),cmp);
                    int flag1=1;
                    for(int i=0;i<tmp.size();i++){
                        if(v[i]==tmp[i]){
                            continue;
                        }
                        if(v[i]>tmp[i]){
                            flag1=0;
                            break;
                        }
                        break;
                    }
                    if(flag1==0){
                        v.clear();
                        for(int i=0;i<tmp.size();i++){
                            v.push_back(tmp[i]);
                        }
                        flag=i;
                    }
                }
                else if(r[flag]>r[i]){
                    flag=i;
                    v.clear();
                    for(int j=1;j<=n;j++){
                        if(visc[j]){
                            continue;
                        }
                        v.push_back(g[i][j]);
                    }
                    sort(v.begin(),v.end());
                }
            }
            visr[flag]=1;
            for(int i=1;i<=n;i++){
                c[i]=-1e18;
            }
            for(int i=1;i<=n;i++){
                if(visr[i]){
                    continue;
                }
                for(int j=1;j<=n;j++){
                    if(visc[j]==1){
                        continue;
                    }
                    c[j]=max(c[j],g[i][j]);
                }
            }
            //cout<<flag<<'\n';
        }
        else{
            int flag=-1;
            vector<int>v;
            for(int i=1;i<=n;i++){
                if(visc[i]){
                    continue;
                }
                if(flag==-1){
                    flag=i;
                    for(int j=1;j<=n;j++){
                        if(visr[j]){
                            continue;
                        }
                        v.push_back(g[i][j]);
                    }
                    sort(v.begin(),v.end());
                }
                else if(c[flag]==c[i]){
                    vector<int>tmp;
                    for(int j=1;j<=n;j++){
                        if(visr[j]){
                            continue;
                        }
                        tmp.push_back(g[j][i]);
                    }
                    sort(tmp.begin(),tmp.end());
                    int flag1=1;
                    //cout<<' '<<v[0]<<'\n';
                    for(int i=0;i<tmp.size();i++){
                        if(tmp[i]==v[i]){
                            continue;
                        }
                        if(tmp[i]>v[i]){
                            //cout<<' '<<i<<'\n';
                            flag1=0;
                            break;
                        }
                        break;
                    }
                    if(flag1==0){
                        flag=i;
                        v.clear();
                        for(int i=0;i<tmp.size();i++){
                            v.push_back(tmp[i]);
                        }
                    }
                }
                else if(c[flag]<c[i]){
                    flag=i;
                    v.clear();
                    for(int j=1;j<=n;j++){
                        if(visr[j]){
                            continue;
                        }
                        v.push_back(g[i][j]);
                        sort(v.begin(),v.end());
                    }
                }
            }
            visc[flag]=1;
            for(int i=1;i<=n;i++){
                r[i]=1e18;
            }
            for(int i=1;i<=n;i++){
                if(visr[i]){
                    continue;
                }
                for(int j=1;j<=n;j++){
                    if(visc[j]==1){
                        continue;
                    }
                    r[i]=min(r[i],g[i][j]);
                }
            }
            //cout<<flag<<'\n';
        }
    }
    for(int i=1;i<=n;i++){
        if(visr[i]){
            continue;
        }
        for(int j=1;j<=n;j++){
            if(visc[j]){
                continue;
            }
            cout<<min(tt[(n*n)/2+1],g[i][j]);
            return;
        }
    }
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
}


详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3552kb

input:

3
1 4 9
8 4 2
7 5 7

output:

5

result:

ok 1 number(s): "5"

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3640kb

input:

50
2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2392 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500
2500 2500 2500 2500 2500 2500 2500 2500 2500 25...

output:

2498

result:

wrong answer 1st numbers differ - expected: '2500', found: '2498'