QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#379282 | #8566. Can We Still Qualify For Semifinals? | ucup-team228# | WA | 1ms | 3844kb | C++20 | 4.6kb | 2024-04-06 16:54:32 | 2024-04-06 16:54:33 |
Judging History
answer
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2") // doesn't work on Yandex
//#pragma GCC target("avx") // for old judges
//#pragma GCC target("bmi,bmi2,lzcnt,popcnt") // fast bit operations
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <chrono>
#include <random>
#include <string>
#include <numeric>
#include <complex>
#include <tuple>
#include <utility>
#include <bitset>
#include <array>
#include <stack>
#include <sstream>
#include <unordered_set>
using namespace std;
typedef long long ll;
string to_string(string a) { return '"' + a + '"'; }
string to_string(char a) { return "'" + string(1, a) + "'"; }
string to_string(const char* a) { return to_string((string) a); }
string to_string(bool a) { return a ? "true" : "false"; }
template <class T1, class T2>
string to_string(pair<T1, T2> a) {
return "(" + to_string(a.first) + ", " + to_string(a.second) + ")";
}
template <class T>
string to_string(T a) {
bool first = true; string res = "{";
for (const auto& i : a) {
if (!first) res += ", ";
first = false;
res += to_string(i);
}
res += "}";
return res;
}
void debug_out() { cerr << endl; }
template <class T1, class... T2>
void debug_out(T1 a, T2... b) {
cerr << " " << to_string(a);
debug_out(b...);
}
#ifdef LOCAL
#define out(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define out(...) 42
#endif
clock_t start_time; void start_timer() { start_time = clock(); }
double get_time() { return (double) (clock() - start_time) / CLOCKS_PER_SEC; }
void Solve();
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
freopen("usr/share/man/man1/input.txt", "r", stdin);
#endif
start_timer();
Solve();
#ifdef LOCAL
cerr << fixed << setprecision(3);
cerr << endl << "Time spent: " << get_time() << endl;
#endif
return 0;
}
// do something, stay focused
// look for stupid bugs
// guess, slow, stress
// don't overgeneralize
// don't rush
// don't waste time on standings
// SOLVE THE PROBLEM OR DIE TRYING
// THE SOLUTION IS ALWAYS SIMPLE
// THE CODE IS ALWAYS SHORT
int bit(int mask, int i) {
return (mask >> i) & 1;
}
const int N = 10;
vector<int> p;
vector<pair<int, int>> ms;
pair<int, int> cnt[N + 1];
pair<int, int> a[N + 1];
void Solve() {
p.resize(10);
iota(p.begin(), p.end(), 1);
for (int r = 1; r <= 9; r++) {
for (int i = 0; i <= 4; i++) {
ms.push_back({p[i], p[9 - i]});
}
int last = p.back();
for (int i = 9; i >= 2; i--) {
p[i] = p[i - 1];
}
p[1] = last;
}
int T;
cin >> T;
while (T--) {
for (int i = 1; i <= N; i++) {
cnt[i] = {0, i};
}
int k;
cin >> k;
for (int i = 0; i < k; i++) {
auto [x, y] = ms[i];
char c;
cin >> c;
if (c == '1') {
cnt[x].first++;
}
else {
cnt[y].first++;
}
}
vector<pair<int, int>> cur;
for (int i = k; i < ms.size(); i++) {
auto [x, y] = ms[i];
if (x == 1 || y == 1) {
cnt[1].first++;
}
else {
cur.push_back({x, y});
}
}
for (int i = 1; i <= N; i++) {
a[i] = cnt[i];
}
int india = cnt[1].first;
bool ok = 0;
for (int mask = 0; mask < (1 << (N + 1)); mask++) {
if (bit(mask, 0) || bit(mask, 1)) continue;
if (__builtin_popcount(mask) > 3) continue;
for (auto [x, y] : cur) {
if (bit(mask, x)) {
a[x].first++;
}
else if (bit(mask, y)) {
a[y].first++;
}
else if (a[x].first < a[y].first) {
a[x].first++;
}
else {
a[y].first++;
}
}
sort(a + 1, a + N + 1);
int fourth = a[7].first;
if (india >= fourth) {
ok = 1;
break;
}
}
if (ok) {
cout << "YES\n";
}
else {
cout << "NO\n";
}
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3844kb
input:
3 3 111 25 1000010101111111111010100 35 01111011110111101111011110111101111
output:
YES YES NO
result:
ok 3 token(s): yes count is 2, no count is 1
Test #2:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
10 16 0110000001010100 17 01111000110110101 15 001100010101111 16 0010101010011100 19 0000000100010110100 16 0011101010011100 18 011110010001100000 18 000110101001100011 20 01100010000100100100 15 001000111001101
output:
YES YES YES YES YES YES YES YES YES YES
result:
ok 10 token(s): yes count is 10, no count is 0
Test #3:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
10 37 0110000001010100011101001011100110001 39 000100111101101001100101101000000000100 35 00111000100111100101011010111100100 33 010000010001110010110001101110001 30 000100010100000010010110101010 31 0000101000011010101001010000000 44 00001000000111101011010110000101100011000100 42 01111011110001001...
output:
NO NO NO NO NO NO NO NO NO NO
result:
ok 10 token(s): yes count is 0, no count is 10
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3732kb
input:
10 23 01100000010101000111010 38 01111001100011000101011110101001101001 27 010000000001001001110001001 26 01101001110011101101000110 8 00001000 22 0110100110001110110001 9 000100010 24 000000100101101010100100 6 011000 29 01101010100101000000000000100
output:
NO NO NO NO YES NO YES NO YES NO
result:
wrong answer expected YES, found NO [1st token]