QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#724791 | #9246. Dominating Point | yld | WA | 0ms | 3884kb | C++20 | 1.5kb | 2024-11-08 15:04:53 | 2024-11-08 15:04:54 |
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);
}
vector<vector<int>> vis(n+1,vector<int>(3));
// vector<int> num(n+1);
int cnt=0;
function<void(int,int)> dfs=[&](int u,int dep)
{
// cout<<u<<endl;
// num[u]++;
vis[u][dep]=1;
if(dep==2) return;
for(auto v:e[u])
{
cnt++;
if(vis[v][1] || (dep==1 && vis[v][2])) continue;
dfs(v,dep+1);
}
};
// vis[1][0]=vis[1][1]=vis[1][2]=1;
// dfs(1,0);
// cout<<cnt<<endl;
// for(int i=1;i<=n;i++) cout<<num[i]<<' ';
vector<int> ans;
for(int i=1;i<=n;i++)
{
cout<<cnt<<endl;
for(int j=1;j<=n;j++) vis[j][1]=vis[j][2]=0;
vis[i][1]=vis[i][2]=1;
dfs(i,0);
int tmp=0;
for(int j=1;j<=n;j++)
if(!vis[j][1] && !vis[j][2]) tmp=1;
if(!tmp) ans.push_back(i);
if(ans.size()>=3) break;
}
if(ans.size()<3) cout<<"NOT FOUND";
else for(int i=0;i<3;i++) cout<<ans[i]<<' ';
cout<<endl;
}
signed main()
{
freopen("1.in","r",stdin);
// cin.tie(0)->sync_with_stdio(0);
int t=1;
while(t--) solve();
cout<<"Time used = "<<(double)clock() / CLOCKS_PER_SEC<<endl;
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3884kb
input:
6 011010 000101 010111 100001 010100 100010
output:
NOT FOUND Time used = 0.000823
result:
wrong output format Expected integer, but "NOT" found