QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#459050 | #7615. Sequence Folding | kia | WA | 263ms | 16428kb | C++17 | 2.1kb | 2024-06-29 21:39:40 | 2024-06-29 21:39:40 |
Judging History
answer
/*
IN THE NAME OF GOD
*/
#include <bits/stdc++.h>
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;
#define F first
#define S second
#define Mp make_pair
#define pb push_back
#define pf push_front
#define size(x) ((ll)x.size())
#define all(x) (x).begin(),(x).end()
#define kill(x) cout << x << '\n', exit(0);
#define fuck(x) cout << "(" << #x << " , " << x << ")" << endl
#define endl '\n'
const int N = 3e5+23, lg = 18;
ll Mod = 1e9+7; //998244353;
inline ll MOD(ll a, ll mod=Mod) {a%=mod; (a<0)&&(a+=mod); return a;}
inline ll poww(ll a, ll b, ll mod=Mod) {
ll ans = 1;
a=MOD(a, mod);
while (b) {
if (b & 1) ans = MOD(ans*a, mod);
b >>= 1;
a = MOD(a*a, mod);
}
return ans;
}
ll t, n, m, a[N], cnt;
unordered_map<ll, int> mp;
int main () {
ios_base::sync_with_stdio(false), cin.tie(0);
cin>>n>>m;
for(int i=1; i<=m; i++) {
cin>>a[i]; mp[a[i]] = 1;
}
ll ans = 0;
while(n > 1) {
for(auto it : mp) {
if(mp.find(n-it.F+1) == mp.end()) mp[n-it.F+1] = 0;
}
unordered_map<ll, int> mp2;
for(auto it : mp) {
if(it.F <= n/2ll) {
int x = mp[n-it.F+1];
if(it.S == x) mp2[it.F] = it.S;
else {
if(x == -1 || it.S == -1) {
mp2[it.F] = max(x, it.S);
} else {
ans++; mp2[it.F] = -1;
}
}
}
}
mp = mp2; n/=(2ll);
}
cout<<ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
8 3 1 5 8
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1 1 1
output:
0
result:
ok single line: '0'
Test #3:
score: -100
Wrong Answer
time: 263ms
memory: 16428kb
input:
17179869184 100000 138476 774165 993977 1152277 1236393 1244970 1534017 1693701 1763926 1778781 1842066 1874644 1885666 2120429 2485344 2977941 3158255 3340476 3504862 4000117 4066652 4197639 4338723 4389163 4576965 4761601 5097091 5175412 5295902 5810551 5855982 6001770 6111262 6163309 6351547 6582...
output:
85077
result:
wrong answer 1st lines differ - expected: '99999', found: '85077'