QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#692409#5520. Distance ParitiesgeorgeyucjrWA 0ms3780kbC++171.0kb2024-10-31 14:28:242024-10-31 14:28:32

Judging History

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

  • [2024-10-31 14:28:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3780kb
  • [2024-10-31 14:28:24]
  • 提交

answer

# include<bits/stdc++.h>
using namespace std;

# define rep(i, f, t, ...) for (int i = f, ##__VA_ARGS__; i <= t; ++i)
# define per(i, f, t, ...) for (int i = f, ##__VA_ARGS__; i >= t; --i)

# define SZ(x) int(x.size())
# define ALL(x) x.begin(), x.end()
# define FILEIO(fn) freopen(fn".in", "r", stdin), freopen(fn".out", "w", stdout)

signed main() {
	// FILEIO("bridge");
	cin.tie(0) -> sync_with_stdio(0);
	auto solve = [&]() {
		int n; cin >> n;
		vector<vector<int> > a(n, vector<int>(n, 0));
		rep(i, 0, n - 1) rep(j, 0, n - 1) { char x; cin >> x, a[i][j] = x - '0'; }
		rep(i, 0, n - 1) rep(j, i + 1, n - 1) if (!a[i][j]) {
			bool flg = false; rep(k, 0, n - 1) if (i != k && j != k)if (a[i][k] && a[j][k]) {flg = true; break;}
			if (!flg)return cout << "Yes\n", void();
		} vector<pair<int, int>>ans; cout << "Yes\n"; rep(i, 0, n - 1)rep(j, i + 1, n - 1)if (a[i][j])ans.emplace_back(i + 1, j + 1);
		cout << SZ(ans) << "\n"; for (auto && [u, v] : ans)cout << u << " " << v << "\n";
	}; int T; cin >> T; while (T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
3
011
101
110
4
0100
1000
0001
0010
5
01010
10101
01010
10101
01010

output:

Yes
3
1 2
1 3
2 3
Yes
Yes
6
1 2
1 4
2 3
2 5
3 4
4 5

result:

wrong output format Expected integer, but "Yes" found (test case 2)