QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#671227 | #9246. Dominating Point | snow_miku# | WA | 0ms | 3820kb | C++20 | 1.3kb | 2024-10-24 11:48:20 | 2024-10-24 11:48:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 5e3 + 5;
bitset<N> G[N];
int main() {
int n; cin >> n;
for (int i = 0;i < n;i++) {
string s; cin >> s;
for (int j = 0;j < s.size();j++) {
G[i][j] = s[j] - '0';
}
}
vector<pair<int, int>> a(n);
for (int i = 0;i < n;i++) {
a[i].first = G[i].count(), a[i].second = i;
}
// auto cmp = [&](int i, int j) -> bool {
// return G[i].count() > G[j].count();
// };
sort(a.rbegin(), a.rend());
// reverse(a.begin(), a.end());
// for (int i = 0;i < n;i++) {
// cout << a[i].second << " " << a[i].first << '\n';
// }
vector<int> ans;
ans.push_back(a[0].second);
for (int i = 1;i < n;i++) {
int tt = a[i].second;
bitset<N> tmp = G[tt];
tmp[tt] = 1;
// cout << tt << ": " << tmp << '\n';
int ok = 1;
for (int x : ans) {
if ((G[x] & tmp) == tmp) {
ok = 0;
break;
}
}
if (ok) ans.push_back(tt);
if (ans.size() >= 3) {
for (int x : ans) {
cout << x + 1 << " ";
}
cout << '\n';
return 0;
}
}
cout << "NOT FONUD" << '\n';
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
input:
6 011010 000101 010111 100001 010100 100010
output:
3 1 6
result:
ok OK, Answer correct.
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3816kb
input:
3 011 001 000
output:
NOT FONUD
result:
wrong answer Wrong Answer, Answer incorrect.