QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#644636#8519. RadarsimfbustWA 0ms3972kbC++142.1kb2024-10-16 14:54:032024-10-16 14:54:04

Judging History

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

  • [2024-10-16 14:54:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3972kb
  • [2024-10-16 14:54:03]
  • 提交

answer

#include<bits/stdc++.h>
#define inf 10000000
using namespace std;
const int N=510;
struct Node{
    int x,y;
    int v;
    bool operator<(const Node&a) const{
        if(x==a.x) return y>a.y;
        return x>a.x;
    }
    bool operator==(const Node&a) const{
        return x==a.x&&y==a.y&&v==a.v;
    }
}now;
int a[N][N];
long long ans;
vector<Node> g;
void init(){
    now.v=inf;
    now.x=0;
    now.y=0;
}
int main(){
    int t,n;
    scanf("%d",&t);
    while(t--){
        ans=0;
        g.clear();
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++) scanf("%d",&a[i][j]);
        }
        if(n==1){
            printf("%d\n",a[n][n]);
            continue;
        }
        init();
        for(int i=1;i<=n/2+1;i++){
            for(int j=1;j<=n/2+1;j++){
                if(a[i][j]<now.v){
                    now.v=a[i][j];
                    now.x=i;
                    now.y=j;
                }
            }
        }
        g.push_back(now);

        init();
        for(int i=1;i<=n/2+1;i++){
            for(int j=n;j>=n/2+1;j--){
                if(a[i][j]<now.v){
                    now.v=a[i][j];
                    now.x=i;
                    now.y=j;
                }
            }
        }
        g.push_back(now);

        init();
        for(int i=n;i>=n/2+1;i--){
            for(int j=1;j<=n/2+1;j++){
                if(a[i][j]<now.v){
                    now.v=a[i][j];
                    now.x=i;
                    now.y=j;
                }
            }
        }
        g.push_back(now);

        init();
        for(int i=n;i>=n/2+1;i--){
            for(int j=n;j>=n/2+1;j--){
                if(a[i][j]<now.v){
                    now.v=a[i][j];
                    now.x=i;
                    now.y=j;
                }
            }
        }
        g.push_back(now);
        sort(g.begin(),g.end());
        ans=g[0].v;
        for(int i=1;i<g.size();i++){
            if(g[i]==g[i-1]) continue;
            else ans+=g[i].v;
        }
        printf("%lld\n",ans);
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3972kb

input:

2
3
1 1 1
1 1 1
1 1 1
5
8 5 2 8 3
5 6 9 7 3
7 8 9 1 4
8 9 4 5 5
2 8 6 9 3

output:

4
5

result:

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