QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#766081 | #9246. Dominating Point | ssmallC233# | TL | 1ms | 5892kb | C++20 | 2.0kb | 2024-11-20 16:08:44 | 2024-11-20 16:08:48 |
Judging History
answer
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#define int long long
using namespace std;
#define pii pair<int, int>
const int MAX = 5e3;
const int N = MAX + 10;
const int INF = 1e18, MOD = 998244353;
int a[N][N], aa[N][N];
inline void solve() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
char ch;
cin >> ch;
if (ch == '0') {
a[i][j] = 0;
} else {
a[i][j] = 1;
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
for (int k = 1; k <= n; k++) {
if ((a[i][k] & a[k][j]) == 1) {
aa[i][j] = 1;
}
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
a[i][j] |= aa[i][j];
}
}
// for (int i = 1; i <= n; i++) {
// for (int j = 1; j <= n; j++) {
// cout << a[i][j];
// }
// cout << "\n";
// }
vector<int> out;
for (int i = 1; i <= n; i++) {
bool ok = true;
for (int j = 1; j <= n; j++) {
if (i == j) continue;
if (a[i][j] == 0) {
ok = false;
break;
}
}
if (ok) {
out.push_back(i);
}
if (out.size() >= 3) break;
}
if (out.size() < 3) {
cout << "NOT FOUND\n";
} else {
for (int x : out) {
cout << x << " ";
}
cout << "\n";
}
}
signed main() {
#ifdef Local
freopen("D:/vs/in.txt", "r", stdin);
// freopen("D:/vs/out.txt","w",stdout);
clock_t start_time = clock();
#else
ios::sync_with_stdio(0);
cin.tie(nullptr);
#endif // Local
int T = 1;
// cin >> T;
while (T--) {
solve();
}
#ifdef Local
cout << "Used " << (double)(clock() - start_time) << " ms" << endl;
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5892kb
input:
6 011010 000101 010111 100001 010100 100010
output:
1 3 4
result:
ok OK, Answer correct.
Test #2:
score: 0
Accepted
time: 1ms
memory: 5600kb
input:
3 011 001 000
output:
NOT FOUND
result:
ok OK, Answer correct.
Test #3:
score: 0
Accepted
time: 1ms
memory: 5656kb
input:
3 010 001 100
output:
1 2 3
result:
ok OK, Answer correct.
Test #4:
score: -100
Time Limit Exceeded
input:
4994 0100001010011001010101110010101000111101111100100001110010000111100000000100110100101000001010100000010010010110110110111010010010100110100000110110111001010111010111010111011001000101001000010001010111110000000100001100000111100011001010010111011100111010101110011000010111101011111110001111110...