QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#766090#9246. Dominating PointssmallC233#ML 1ms5904kbC++202.1kb2024-11-20 16:10:272024-11-20 16:10:28

Judging History

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

  • [2024-11-22 18:38:25]
  • hack成功,自动添加数据
  • (/hack/1238)
  • [2024-11-20 16:10:28]
  • 评测
  • 测评结果:ML
  • 用时:1ms
  • 内存:5904kb
  • [2024-11-20 16:10:27]
  • 提交

answer

#include <bits/stdc++.h>
// #pragma GCC optimize(2)
#define int long long
using namespace std;
#define pii pair<int, int>
const int MAX = 5e3;
const int N = MAX + 10;
const int INF = 1e18, MOD = 998244353;

int a[N][N], aa[N][N];

inline void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            char ch;
            cin >> ch;
            if (ch == '0') {
                a[i][j] = 0;
            } else {
                a[i][j] = 1;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                if ((a[i][k] & a[k][j]) == 1) {
                    aa[i][j] = 1;
                    break;
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            a[i][j] |= aa[i][j];
        }
    }

    // for (int i = 1; i <= n; i++) {
    //     for (int j = 1; j <= n; j++) {
    //         cout << a[i][j];
    //     }
    //     cout << "\n";
    // }

    vector<int> out;
    for (int i = 1; i <= n; i++) {
        bool ok = true;
        for (int j = 1; j <= n; j++) {
            if (i == j) continue;
            if (a[i][j] == 0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            out.push_back(i);
        }
        if (out.size() >= 3) break;
    }
    if (out.size() < 3) {
        cout << "NOT FOUND\n";
    } else {
        for (int x : out) {
            cout << x << " ";
        }
        cout << "\n";
    }
}

signed main() {
#ifdef Local
    freopen("D:/vs/in.txt", "r", stdin);
    // freopen("D:/vs/out.txt","w",stdout);
    clock_t start_time = clock();
#else
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
#endif  // Local
    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }
#ifdef Local
    cout << "Used " << (double)(clock() - start_time) << " ms" << endl;
#endif
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5608kb

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

input:

3
011
001
000

output:

NOT FOUND

result:

ok OK, Answer correct.

Test #3:

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

input:

3
010
001
100

output:

1 2 3 

result:

ok OK, Answer correct.

Test #4:

score: -100
Memory Limit Exceeded

input:

4994
0100001010011001010101110010101000111101111100100001110010000111100000000100110100101000001010100000010010010110110110111010010010100110100000110110111001010111010111010111011001000101001000010001010111110000000100001100000111100011001010010111011100111010101110011000010111101011111110001111110...

output:

1 2 3 

result: