QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#607724 | #7615. Sequence Folding | qiuuu | WA | 1ms | 3804kb | C++14 | 859b | 2024-10-03 15:59:46 | 2024-10-03 15:59:48 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100009;
set<LL> st;
map<LL,int> mp0,mp1;
LL n,m,a[N];
int main()
{
//freopen("1.txt","r",stdin);
scanf("%lld%lld",&n,&m);
for(int i=1;i<=m;i++)
scanf("%lld",&a[i]),mp0[a[i]]=1,mp1[a[i]]=0,st.insert(min(n-a[i]+1,a[i]));
while(n>1)
{
for(int i:st)
{
if(!mp1.count(i)) mp1[i]=1;
if(!mp1.count(n-i+1)) mp1[n-i+1]=1;
int tmp1,tmp2;
tmp1=min({mp0[i]+mp0[n-i+1],mp0[i]+mp1[n-i+1]+1,mp1[i]+mp0[n-i+1]+1});
tmp2=min({mp1[i]+mp1[n-i+1],mp0[i]+mp1[n-i+1]+1,mp1[i]+mp0[n-i+1]+1});
mp0[i]=tmp1;
mp1[i]=tmp2;
mp0.erase(n-i+1);
mp1.erase(n-i+1);
}
m=0;
for(auto i:st) a[++m]=min(i,n-i+1);
n/=2;
st.clear();
for(int i=1;i<=m;i++) st.insert(a[i]);
}
printf("%d",min(mp0[1],mp1[1]));
}
/*
8 3
1 5 8
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3804kb
input:
8 3 1 5 8
output:
0
result:
wrong answer 1st lines differ - expected: '2', found: '0'