QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#302770#7995. 图wifi32767WA 2ms5948kbC++201.3kb2024-01-11 12:15:502024-01-11 12:15:50

Judging History

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

  • [2024-01-11 12:15:50]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5948kb
  • [2024-01-11 12:15:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define yes cout << "You win, temporarily.\n"
#define no cout << "Wasted.\n"
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
const int MAX = 500 + 10, inf = 2147483647, mod = 998244353;

int n;
int grid[MAX][MAX];
ll dis[MAX][MAX];
bool ans[MAX][MAX];
vector<array<int, 3>> e;
void solve(){
	cin >> n;
	for (int i = 1; i <= n; ++ i){
		for (int j = 1; j <= n; ++ j){
			cin >> grid[i][j];
			dis[i][j] = grid[i][j];
		}
	}
	for (int i = 1; i <= n; ++ i){
		for (int j = 1; j <= n; ++ j){
			for (int k = 1; k <= n; ++ k){
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	for (int i = 1; i <= n; ++ i){
		for (int j = 1; j <= n; ++ j){
			if (i == j or dis[i][j] < grid[i][j]) continue;
			ans[i][j] = 1;
			for (int k = 1; k <= n; ++ k){
				if (k == i or k == j) continue;
				if (dis[i][j] == dis[i][k] + dis[k][j]){
					ans[i][j] = 0;
					break;
				}
			}
		}
	}
	for (int i = 1; i <= n; ++ i){
		for (int j = 1; j <= n; ++ j) cout << ans[i][j];
		cout << endl;
	}
}
signed main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//cout << fixed << setprecision(7);
	//int _;cin>>_;while (_ --)
		solve();
}

详细

Test #1:

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

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: 5460kb

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: -100
Wrong Answer
time: 2ms
memory: 5948kb

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:

0000000000000000000001000000000000000010000110000000100001001000000000000001000000000000000000000010
0011000000100000000000000000000000000000000000000000000000100000000000000000000000000000000000000000
01001000010000001000000001000000000000000000000000001000000010000000000010000000010000000000000000...

result:

wrong answer 1st lines differ - expected: '000000000000000000000000000000...0000001000000000000000000000010', found: '000000000000000000000100000000...0000001000000000000000000000010'