QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#719001 | #9246. Dominating Point | yld# | WA | 0ms | 3860kb | C++20 | 1.2kb | 2024-11-06 22:00:28 | 2024-11-06 22:00:28 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve()
{
int n;cin>>n;
vector<int> e[n+1];
for(int i=1;i<=n;i++)
{
string s;cin>>s;
s=' '+s;
for(int j=1;j<=n;j++)
if(s[j]=='1')e[i].push_back(j);
}
// for(int i=1;i<=n;i++)
// {
// for(auto x:e[i]) cout<<i<<' '<<x<<endl;
// }
vector<int> vis(n+1);
function<void(int,int)> dfs=[&](int u,int dep)
{
vis[u]=1;
if(dep==2) return;
for(auto v:e[u])
dfs(v,dep+1);
};
vector<int> ans;
for(int i=1;i<=n;i++)
{
fill(vis.begin(),vis.end(),0);
dfs(i,0);
int tmp=0;
// cout<<i<<endl;
for(int i=1;i<=n;i++)
{
if(vis[i]==0)
{
// cout<<i<<' ';
tmp=1;
}
}
// cout<<endl;
if(!tmp) ans.push_back(i);
}
if(ans.size()<3) cout<<"NOT FOUND\n";
else
for(int i=0;i<3;i++)
cout<<ans[i]<<' ';
cout<<endl;
}
signed main()
{
cin.tie(0)->sync_with_stdio(0);
int t=1;
while(t--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
input:
6 011010 000101 010111 100001 010100 100010
output:
1 3 4
result:
ok OK, Answer correct.
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3860kb
input:
3 011 001 000
output:
NOT FOUND
result:
wrong output format Expected EOF