QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#767484 | #9246. Dominating Point | 1903331632 | TL | 1ms | 5664kb | C++23 | 1.7kb | 2024-11-20 21:05:17 | 2024-11-20 21:05:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(s) s.begin(), s.end()
#define int long long
#define endl '\n'
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
int n, k;
char mp[5005][5005];
vector<int> side[5005];
bool bfs(int x)
{
queue<int> q;
q.push(x);
map<int, int> st;
st[x] = 1;
while (!q.empty())
{
int u = q.front();
q.pop();
for (int v : side[u])
{
if (st[v])
continue;
q.push(v);
}
}
return true;
}
void solve()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
cin >> mp[i][j];
if (mp[i][j] == '1')
{
side[i].push_back(j);
}
}
}
vector<int> res;
for (int i = 1; i <= n; i++)
{
map<int, int> st;
st[i] = 1;
for (int u : side[i])
{
st[u] = 1;
for (int v : side[u])
{
st[v] = 1;
}
}
// for (auto t : st)
// {
// cout << t.first << " " << t.second << endl;
// }
// cout << endl;
if (st.size() == n)
{
res.push_back(i);
}
}
// for (auto t : res)
// {
// cout << t << ' ';
// }
// cout << endl;
// return;
if (res.size() >= 3)
{
cout << res[0] << ' ' << res[1] << ' ' << res[2] << endl;
}
else
cout << "NOT FOUND" << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3444kb
input:
6 011010 000101 010111 100001 010100 100010
output:
1 3 4
result:
ok OK, Answer correct.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
3 011 001 000
output:
NOT FOUND
result:
ok OK, Answer correct.
Test #3:
score: 0
Accepted
time: 0ms
memory: 5664kb
input:
3 010 001 100
output:
1 2 3
result:
ok OK, Answer correct.
Test #4:
score: -100
Time Limit Exceeded
input:
4994 0100001010011001010101110010101000111101111100100001110010000111100000000100110100101000001010100000010010010110110110111010010010100110100000110110111001010111010111010111011001000101001000010001010111110000000100001100000111100011001010010111011100111010101110011000010111101011111110001111110...