QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#669140 | #9253. Prism Palace | mzyx | WA | 0ms | 3628kb | C++20 | 1.4kb | 2024-10-23 17:24:50 | 2024-10-23 17:24:54 |
Judging History
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