QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#657431#9246. Dominating PointVegetog#TL 1ms5648kbC++201.3kb2024-10-19 14:45:332024-10-19 14:45:33

Judging History

你现在查看的是最新测评结果

  • [2024-11-22 18:38:25]
  • hack成功,自动添加数据
  • (/hack/1238)
  • [2024-10-19 14:45:33]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:5648kb
  • [2024-10-19 14:45:33]
  • 提交

answer

 #include<bits/stdc++.h>
#define int long long
using namespace std;
using ll =long long;
const int N=5000+6;

char a[N][N];
int b[N][N];

void solve()
{
    int n;cin>>n;
    vector<vector<int>> g(n+1);
    vector<vector<int>> h(n+1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>a[i][j];
            if(a[i][j]=='1'){
                g[i].push_back(j);
            }
        }
    }


    for(int i=1;i<=n;i++){
        for(auto it : g[i]){
            for(auto jt : g[it]){
                h[i].push_back(jt);
                b[i][jt]=it;
            }
        }
    }

    vector<int> ans;

    for(int i=1;i<=n;i++){
        int cnt=0;
        for(int j=1;j<=n;j++){
            if(i==j||a[i][j]=='1'){
                cnt++;
                continue;
            }
            if(b[i][j]>0){
                cnt++;
            }
        }
        if(cnt==n){
            ans.push_back(i);
        }
        if(ans.size()==3){
            for(auto it : ans){
                cout<<it<<" ";
            }
            cout<<"\n";
            return ;
        }
    }
    cout<<"NOT FOUND"<<"\n";
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr),cout.tie(nullptr);

    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: 5648kb

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: 5596kb

input:

3
011
001
000

output:

NOT FOUND

result:

ok OK, Answer correct.

Test #3:

score: 0
Accepted
time: 1ms
memory: 5592kb

input:

3
010
001
100

output:

1 2 3 

result:

ok OK, Answer correct.

Test #4:

score: -100
Time Limit Exceeded

input:

4994
0100001010011001010101110010101000111101111100100001110010000111100000000100110100101000001010100000010010010110110110111010010010100110100000110110111001010111010111010111011001000101001000010001010111110000000100001100000111100011001010010111011100111010101110011000010111101011111110001111110...

output:


result: