QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#393906#7995. 图OOBMABTRAMS#TL 911ms10836kbC++17977b2024-04-19 16:44:202024-04-19 16:44:20

Judging History

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

  • [2024-04-19 16:44:20]
  • 评测
  • 测评结果:TL
  • 用时:911ms
  • 内存:10836kb
  • [2024-04-19 16:44:20]
  • 提交

answer

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

ll a[N][N];
ll dis[N][N][2];
ll ans[N][N];
void upd(int i,int j,ll v){
    if(dis[i][j][0]>=v)dis[i][j][1]=dis[i][j][0],dis[i][j][0]=v;
    else if(dis[i][j][1]>=v)dis[i][j][1]=v;
}
void solve(){
    int n;
    cin>>n;
    memset(dis,63,sizeof dis);
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)cin>>dis[i][j][0],a[i][j]=dis[i][j][0];
    for(int i=1;i<=n;i++)dis[i][i][0]=dis[i][i][1];
    for(int k=1;k<=n;k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
        upd(i,j,dis[i][k][0]+dis[k][j][0]);
        upd(i,j,dis[i][k][1]+dis[k][j][0]);
        upd(i,j,dis[i][k][0]+dis[k][j][1]);
    }

    for(int i=1;i<=n;cout<<'\n',i++)for(int j=1;j<=n;j++){
        cout<<(i!=j&&dis[i][j][0]!=dis[i][j][1]&&a[i][j]==dis[i][j][0]);
    }
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T=1;
    //cin>>T;
    while(T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 9824kb

input:

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

output:

0110
1000
1001
0010

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 7764kb

input:

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

output:

0110
1000
1001
0010

result:

ok 4 lines

Test #3:

score: 0
Accepted
time: 9ms
memory: 9824kb

input:

100
0 41659 61282 49636 67326 48035 29694 46438 87384 82143 38685 66540 48746 29800 91786 54931 56232 61941 53423 75707 45135 69244 53802 89998 64199 63778 75825 31745 66975 44537 35793 55663 72647 60768 80884 46657 54066 84568 6266 48213 78216 50369 66761 54861 67607 38509 52250 54210 71135 56840 5...

output:

0000000000000000000000000000000000000010000100000000100001001000000000000001000000000000000000000010
0011000000100000000000000000000000000000000000000000000000100000000000000000000000000000000000000000
01001000010000000000000000000000000000000000000000001000000010000000000010000000010000000000000000...

result:

ok 100 lines

Test #4:

score: 0
Accepted
time: 9ms
memory: 8076kb

input:

100
0 81722 50546 79959 47292 51747 54712 7396 58005 52529 61319 66453 61823 76359 55454 60837 29465 61066 66711 75051 58395 38189 44176 32315 39742 46514 23229 27872 59119 39600 81204 45383 59424 40396 51094 74411 16551 30485 42587 18676 82697 76869 48206 41961 44633 59558 41795 57384 59943 18175 4...

output:

0000000100000000000000000000000000000000000000000100000000000001000000000000000100000000000000000000
0000000000000001010100000000000000000000000000000000000100000000001000000000000000000000000000000000
00000000001000001000000000001000000000000000000000000000000000000000100000001000000001000000000000...

result:

ok 100 lines

Test #5:

score: 0
Accepted
time: 7ms
memory: 9832kb

input:

100
0 1 2 1 2 1 1 1 1 1 1 1 1 2 2 2 2 2 1 2 2 2 2 2 1 1 2 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 2 1 1 1 1 1 1 2 1 1 2 2 1 1 1 2 2 1 1 2 1 2 1 2 1 2 2 2 1 1 2 1 2 3 1 1 2 2 2 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 1
1 0 1 1 1 2 3 2 2 1 1 1 1 2 2 1 3 3 2 2 1 3 2 2 2 1 3 2 2 1 1 2 2 3 1 2 1 1 1 1 1 2 3 2 1 1 2 1 ...

output:

0101011111111000001000001101111111111001110111111011001110011010101000110100110001111011011111111011
1011100001111001000010000100011000101111100011010110000111101011101000010001010111011010111011101101
01000011010010010111101101101111110111110000101000101111100010110010011100110101101010100000110011...

result:

ok 100 lines

Test #6:

score: 0
Accepted
time: 10ms
memory: 9880kb

input:

100
0 2 2 1 2 2 2 2 1 2 2 2 1 1 2 1 2 1 2 2 2 3 2 2 2 2 1 1 1 2 1 2 1 2 1 2 1 2 2 2 2 1 1 1 1 1 1 2 2 2 1 1 2 2 2 1 2 2 1 1 3 1 1 2 2 2 2 1 2 1 3 2 1 2 1 1 1 1 2 2 1 1 1 2 2 2 1 2 2 1 1 2 1 1 3 1 1 3 2 1
2 0 1 1 2 1 2 2 2 2 1 3 2 2 2 1 1 1 2 3 1 1 1 2 1 2 2 2 1 1 2 2 1 1 2 1 1 2 2 1 2 1 1 1 2 2 1 1 ...

output:

0001000010001101010000000011101010101000011111100011000100110110000101001011110011100010011011011001
0011010000100001110011101000110011011001011100110110101100010010000110100111100111111010101001011011
01010001110101001110100011100011010010110000110001110101101010111001101010110001101110011101010111...

result:

ok 100 lines

Test #7:

score: 0
Accepted
time: 871ms
memory: 10580kb

input:

500
0 743810 457854 85842 793418 318922 803556 939014 213357 346386 67230 841985 991820 600886 111369 198349 745203 809216 581207 443436 374000 684975 536767 444827 513284 841566 95714 870537 213411 507714 279089 852847 236477 266161 457883 432456 181558 6690 709759 89446 718063 263025 285303 124290...

output:

000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000...

result:

ok 500 lines

Test #8:

score: 0
Accepted
time: 911ms
memory: 9648kb

input:

500
0 2 2 8 1 5 10 7 6 9 5 9 2 4 8 6 5 3 1 3 3 10 7 1 7 9 10 9 6 6 9 2 8 9 10 10 1 5 5 9 6 5 8 8 6 5 6 2 3 3 10 10 8 4 10 9 6 6 6 6 2 9 6 5 4 3 7 8 6 1 6 4 1 9 5 8 9 2 7 6 8 1 1 8 7 7 4 3 5 10 4 1 8 1 6 9 6 6 10 8 8 10 1 10 4 9 2 4 5 5 4 4 8 1 3 8 8 4 1 8 1 8 3 8 2 6 2 4 9 2 10 7 9 1 10 9 7 1 4 1 9 ...

output:

000010000000000000100001000000000000100000000000000000000000000000000100100000000110000000010100000000100000000001000010100000000000010001010000100000000000000000000000000000010000000010000100000000101001000010000000000000010000100000000000000001100100000010000000000000010100000100000000000000000000...

result:

ok 500 lines

Test #9:

score: 0
Accepted
time: 834ms
memory: 10836kb

input:

500
0 14893 9715 8418 11689 7914 12453 6215 7449 8307 13288 8074 7145 7404 7035 6513 10885 7276 7395 9395 7329 6788 2571 11164 8363 6852 5689 3704 3170 13069 10644 6587 9992 8314 11542 8168 11649 8763 5142 7790 5867 5745 13489 9658 9898 6896 7174 4354 5776 9910 7437 6110 6612 4468 8756 2310 5397 982...

output:

000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000010000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010000000000000...

result:

ok 500 lines

Test #10:

score: 0
Accepted
time: 836ms
memory: 10640kb

input:

500
0 13216 9169 13904 1547 16781 11728 10087 14614 7941 15600 7706 20640 10377 12331 14186 9601 11270 13364 10161 10522 8487 11492 17192 12168 16538 9189 12061 10379 11223 9937 11564 6284 13004 7186 11204 14242 8111 6926 10945 12755 13084 4181 11593 11193 15592 15546 8845 9903 5180 14922 12151 9823...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000...

result:

ok 500 lines

Test #11:

score: -100
Time Limit Exceeded

input:

500
0 1 1 1 1 2 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 2 2 1 2 1 1 1 2 1 1 1 2 2 2 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 2 1 1 2 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 2 1 1 1 2 1 1 1 1 2 1 1 2 1 1 2 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 ...

output:


result: