QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#772019 | #9246. Dominating Point | SunsetGlow95 | TL | 997ms | 6944kb | C++14 | 1.2kb | 2024-11-22 16:38:07 | 2024-11-22 16:38:07 |
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), ++deg[j];
}
perm[i] = i;
}
if (*min_element(deg, deg + N) == 0) {
cout << "NOT FOUND" << endl;
return 0;
}
sort(perm, perm + N, [](int x, int y) { return ex[x].count() > ex[y].count(); });
vector<int> ans;
mt19937 rnd(random_device{}());
for (int i(0), j(0); i != N; i = j) {
while (j != N && ex[perm[i]].count() == ex[perm[j]].count()) ++j;
shuffle(perm + i, perm + j, rnd);
}
for (int i(0); i != min(N, 100); ++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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3652kb
input:
6 011010 000101 010111 100001 010100 100010
output:
3 1 4
result:
ok OK, Answer correct.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
3 011 001 000
output:
NOT FOUND
result:
ok OK, Answer correct.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
3 010 001 100
output:
1 3 2
result:
ok OK, Answer correct.
Test #4:
score: 0
Accepted
time: 997ms
memory: 6944kb
input:
4994 0100001010011001010101110010101000111101111100100001110010000111100000000100110100101000001010100000010010010110110110111010010010100110100000110110111001010111010111010111011001000101001000010001010111110000000100001100000111100011001010010111011100111010101110011000010111101011111110001111110...
output:
1505 153 914
result:
ok OK, Answer correct.
Test #5:
score: -100
Time Limit Exceeded
input:
4994 0000000110000010100001001010100101010001000000011001110000111011100010100100001001011100000101100000100100001101101101010010110011101100101001100101110010001111110111001101000110111001010011101001010101000000111101101111001011111011000001110010000000110101010010010100100101111111001000111111011...
output:
4094 4675 3437