QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#771890#9246. Dominating PointSunsetGlow95TL 0ms3616kbC++141.0kb2024-11-22 16:11:472024-11-22 16:11:47

Judging History

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

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

answer

#include <bits/stdc++.h>
using namespace std;

const int MXN = 5005;
int N, deg[MXN], perm[MXN];
bitset<MXN> ex[MXN], tmp;

bool check(int p) {
  tmp = ex[p];
  tmp.set(p);
  for (int i(0); i != N; ++i)
    if (ex[p][i]) tmp |= ex[i];
  return tmp.count() == N;
}

int main() {
  cin >> N;
  for (int i(0); i != N; ++i) {
    char c(0);
    for (int j(0); j != N; ++j) {
      cin >> c;
      if (c == '1') ex[i].set(j);
    }
    perm[i] = i;
  }
  for (int i(0); i != N; ++i) {
    deg[i] = ex[i].count();
    for (int j(0); j != N; ++j) {
      if (ex[i][j]) deg[i] += ex[j].count();
    }
  }
  sort(perm, perm + N, [](int x, int y) { return deg[x] < deg[y]; });
  vector<int> ans;
  for (int i(0); i != min(N, 80); ++i) {
    if (check(perm[i])) {
      ans.push_back(perm[i]);
      if (ans.size() == 3) break;
    }
  }
  if (ans.size() == 3) {
    cout << ans[0] + 1 << ' ' << ans[1] + 1 << ' ' << ans[2] + 1 << endl;
  } else {
    cout << "NOT FOUND" << endl;
  }
  return 0;
}

詳細信息

Test #1:

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

input:

6
011010
000101
010111
100001
010100
100010

output:

4 6 1

result:

ok OK, Answer correct.

Test #2:

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

input:

3
011
001
000

output:

NOT FOUND

result:

ok OK, Answer correct.

Test #3:

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

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: