QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#747930 | #7615. Sequence Folding | inksamurai | WA | 0ms | 3500kb | C++23 | 1.2kb | 2024-11-14 18:46:39 | 2024-11-14 18:46:40 |
Judging History
answer
#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define vec(...) vector<__VA_ARGS__>
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
void slv(){
int n,m;
cin>>n>>m;
map<int,int> mp;
rep(i,m){
int x;
cin>>x;
mp[x]=1;
}
int ans=0;
while(n){
map<int,int> ne_map;
for(auto [x,c]:mp){
int y=n-x+1;
int rc=mp.find(y)==mp.end()?0:mp[y];
if(c==rc){
ne_map[x]=ne_map[y]=c;
}else{
int nec;
if(c!=-1 and rc!=-1){
ans+=1;
nec=-1;
}else if(c!=-1 or rc!=-1){
nec=max(c,rc);
}else{
nec=-1;
}
ne_map[x]=ne_map[y]=nec;
}
}
mp.swap(ne_map);
// print(ans);
// for(auto [x,c]:mp){
// print(x,c);
// }
n/=2;
}
print(ans);
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0);
int t;
// cin>>t;
t=1;
rep(cs,t){
slv();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3500kb
input:
8 3 1 5 8
output:
4
result:
wrong answer 1st lines differ - expected: '2', found: '4 '