QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#669140#9253. Prism PalacemzyxWA 0ms3628kbC++201.4kb2024-10-23 17:24:502024-10-23 17:24:54

Judging History

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

  • [2024-10-23 17:24:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-10-23 17:24:50]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize(3)

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n;
	cin >> n;
	
	string g[n];
	for (int i = 0; i < n; i++) {
		cin >> g[i];
	}
	
	vector<vector<int>> adj(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (g[i][j] == '1') {
				adj[i].push_back(j);
			}
		}
	}
	
	auto bfs = [&](int u) -> bool {
		vector<vector<int>> vis(n, vector<int>(3));
		queue<pair<int, int>> q;
		q.push({u, 0});
		while (!q.empty()) {
			auto [x, step] = q.front();
			q.pop();
			
			if (vis[x][step]) {
				continue;
			}
			vis[x][step] = 1;
			if (step >= n) {
				break;
			}
			
			for (auto y : adj[x]) {
				if (!vis[y][step + 1]) {
					q.push({y, step + 1});
				}
			}
		}
		
		// cerr << "f" << "\n";
		// cerr << u << "\n";
		// for (int i = 0; i < n; i++) {
		// 	cerr << vis[i][0] << " " << vis[i][1] << "\n";
		// }
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (vis[i][0] || vis[i][1] || vis[i][2]) {
				cnt++;
			}
		}
		
		return cnt >= n;
	};
	
	vector<int> ans;
	for (int i = 0; i < n; i++) {
		if (bfs(i)) {
			ans.push_back(i + 1);
		}
		if (ans.size() >= 3) {
			break;
		}
	}
	
	if (ans.size() >= 3) {
		cout << ans[0] << " " << ans[1] << " " << ans[2] << "\n";
	} else {
		cout << "NOT FOUND" << "\n";
	}
	
	return 0;
}

详细

Test #1:

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

input:

3
0 0
1 0
0 1

output:

NOT FOUND

result:

wrong output format Expected double, but "NOT" found