QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#767491#9246. Dominating Point1903331632TL 0ms3788kbC++231.7kb2024-11-20 21:06:362024-11-20 21:06:39

Judging History

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

  • [2024-11-22 18:38:25]
  • hack成功,自动添加数据
  • (/hack/1238)
  • [2024-11-20 21:06:39]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3788kb
  • [2024-11-20 21:06:36]
  • 提交

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);
        }
        if (res.size() == 3)
            break;
    }
    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();
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3548kb

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

input:

3
011
001
000

output:

NOT FOUND

result:

ok OK, Answer correct.

Test #3:

score: 0
Accepted
time: 0ms
memory: 3788kb

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: