QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#771890 | #9246. Dominating Point | SunsetGlow95 | TL | 0ms | 3616kb | C++14 | 1.0kb | 2024-11-22 16:11:47 | 2024-11-22 16:11:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int MXN = 5005;
int N, deg[MXN], perm[MXN];
bitset<MXN> ex[MXN], tmp;
bool check(int p) {
tmp = ex[p];
tmp.set(p);
for (int i(0); i != N; ++i)
if (ex[p][i]) tmp |= ex[i];
return tmp.count() == N;
}
int main() {
cin >> N;
for (int i(0); i != N; ++i) {
char c(0);
for (int j(0); j != N; ++j) {
cin >> c;
if (c == '1') ex[i].set(j);
}
perm[i] = i;
}
for (int i(0); i != N; ++i) {
deg[i] = ex[i].count();
for (int j(0); j != N; ++j) {
if (ex[i][j]) deg[i] += ex[j].count();
}
}
sort(perm, perm + N, [](int x, int y) { return deg[x] < deg[y]; });
vector<int> ans;
for (int i(0); i != min(N, 80); ++i) {
if (check(perm[i])) {
ans.push_back(perm[i]);
if (ans.size() == 3) break;
}
}
if (ans.size() == 3) {
cout << ans[0] + 1 << ' ' << ans[1] + 1 << ' ' << ans[2] + 1 << endl;
} else {
cout << "NOT FOUND" << endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
input:
6 011010 000101 010111 100001 010100 100010
output:
4 6 1
result:
ok OK, Answer correct.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
3 011 001 000
output:
NOT FOUND
result:
ok OK, Answer correct.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
3 010 001 100
output:
1 2 3
result:
ok OK, Answer correct.
Test #4:
score: -100
Time Limit Exceeded
input:
4994 0100001010011001010101110010101000111101111100100001110010000111100000000100110100101000001010100000010010010110110110111010010010100110100000110110111001010111010111010111011001000101001000010001010111110000000100001100000111100011001010010111011100111010101110011000010111101011111110001111110...