QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#226226 | #7618. Pattern Search | ucup-team1001 | WA | 0ms | 3716kb | C++20 | 1.6kb | 2023-10-25 18:38:14 | 2023-10-25 18:38:15 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
using ll = long long;
#define endl "\n"
ll n, m;
set<ll> a1, a2;
void print() {
for (int i = 1; i <= n; ++i) {
if (a1.find(i) != a1.end())cout << 1;
else if (a2.find(i) != a2.end())cout << 2;
else cout << 0;
}
cout << endl;
for (auto &&i: a1) {
cout << i << " ";
}
cout << endl;
for (auto &&i: a2) {
cout << i << " ";
}
cout << endl;
}
int main() {
cin >> n >> m;
for (ll i = 0; i < m; ++i) {
ll x;
cin >> x;
a1.insert(x);
}
ll ans = 0;
while (n != 1) {
// print();
for (auto i = a1.begin(); i != a1.end();) {
if (*i > n)break;
auto r = n + 1 - *i;
if (a1.find(r) != a1.end()) {
++i;
continue;
}
if (a2.find(r) != a2.end()) {
++i;
continue;
}
ans++;
a2.insert(*i);
a2.insert(r);
i = a1.erase(i);
}
for (auto i = a2.begin(); i != a2.end();) {
if (*i > n)break;
auto r = n + 1 - *i;
if (a2.find(r) != a2.end()) {
++i;
continue;
}
if (a1.find(r) != a1.end()) {
a1.insert(*i);
i = a2.erase(i);
} else {
i = a2.erase(i);
}
}
n >>= 1;
}
// print();
cout << ans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3716kb
input:
2 bajkaaall aal abca cba
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'