QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#229006#7615. Sequence FoldingwangqingxianWA 1976ms179860kbC++141.2kb2023-10-28 14:47:182023-10-28 14:47:19

Judging History

你现在查看的是最新测评结果

  • [2023-10-28 14:47:19]
  • 评测
  • 测评结果:WA
  • 用时:1976ms
  • 内存:179860kb
  • [2023-10-28 14:47:18]
  • 提交

answer

#include<algorithm>
#include<vector>
#include<cstdio>
#include<map>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<queue>
#include<iomanip>
#include<stdlib.h>
#include<set>
#include<cassert>
#include<cmath>
#define int long long
#define y0 ahfweaipuhrfil
#define y1 sdafjhiuhfalwu
#define x0 adlkhfguywelsj
#define x1 guyoago2o8iraj
#define lowbit(i) (i&-i)
using namespace std;
const int N=3e3+10,inf=0x7fffffff,mod=1e9+7;
int n,m;
int ans=0;
set<int> s;
map<int,int> f[2];
signed main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int a;
        cin>>a;
        s.insert(a);
        f[1][a]=0;f[0][a]=1;
    }
    int kkk=0;
    while(n>2){
        set<int> s1;
        for(auto i:s){
            int k=min(i,n-i+1);
            if(s.count(n-i+1)){
                f[1][k]=f[1][i]+f[1][n-i+1];
                f[0][k]=f[0][i]+f[0][n-i+1];
                s1.insert(k);
            }
            else{
                f[1][k]=f[1][i]+(1<<kkk);
                f[0][k]=f[0][i]+f[0][n-i+1];
                s1.insert(k);
            }
        }
        swap(s,s1);
        n>>=1;
        kkk<<=1;
    }
    cout<<min(f[1][1],f[0][1])<<endl;
    return 0;
}
/*
 
 8 3
 1 5 8
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3468kb

input:

8 3
1 5 8

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3424kb

input:

1 1
1

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 1976ms
memory: 179860kb

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:

34774583

result:

wrong answer 1st lines differ - expected: '99999', found: '34774583'