QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#393896#7995. 图OOBMABTRAMS#WA 1ms7696kbC++17950b2024-04-19 16:33:352024-04-19 16:33:36

Judging History

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

  • [2024-04-19 16:33:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7696kb
  • [2024-04-19 16:33:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=503;

ll a[N][N];
ll dis[N][N];
ll ans[N][N];
void solve(){
    int n;
    cin>>n;
    vector<tuple<int,int,int>>eg;
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
        cin>>a[i][j];
        if(i>j)eg.emplace_back(a[i][j],i,j);
    }
    memset(dis,63,sizeof dis);
    for(int i=1;i<=n;i++)dis[i][i]=0;
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(i!=j)ans[i][j]=1;
    sort(eg.begin(), eg.end());
    for(auto[l,x,y]:eg){
        if(l>=dis[x][y])ans[x][y]=ans[y][x]=0;
        for(int i=1;i<=n;i++)dis[i][x]=dis[x][i]=min(dis[i][y]+l,dis[x][i]);
        for(int i=1;i<=n;i++)dis[i][y]=dis[y][i]=min(dis[i][x]+l,dis[y][i]);
    }
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)cout<<ans[i][j]<<" \n"[j==n];
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T=1;
    //cin>>T;
    while(T--)solve();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7696kb

input:

4
0 3 2 100
3 0 8 100
2 8 0 10
100 100 10 0

output:

0 1 1 0
1 0 0 0
1 0 0 1
0 0 1 0

result:

wrong answer 1st lines differ - expected: '0110', found: '0 1 1 0'