답안 #58564

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
58564 2018-07-18T08:10:51 Z Batrr Palindrome-Free Numbers (BOI13_numbers) C++14
72.5 / 100
4 ms 1048 KB
#include <bits/stdc++.h>
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
*/
#define ll long long                   
#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 
#define IOS ios_base::sync_with_stdio(0);

using namespace std;                    

const ll maxn=2e5+123,inf=1e18,mod=1e9+7,N=360360,LOG=20;
ll a,b,ans;
vector<int> av,bv;
vector<int> tov(ll x){
    vector<int> res;
    while(x){
        res.pb(x%10);
        x/=10;
    }
    reverse(res.begin(),res.end());
    return res;
}
ll calc(int a,int b,int len){
    if(len==0)
        return 1;
    ll res=1;
    if(b==-1)
        res=9,len--;    
    while(len--)
        res*=8;
    return res;
}
ll get(vector<int> s){
    ll res=pow(8,s.size()-2)*9;
    //cout<<res<<endl;
    for(int i=0;i<s.size();i++){
        int a,b,c;
        a=b=-1;
        if(i>1)
            a=s[i-2];
        if(i>0)
            b=s[i-1];
        for(int j=(i==0);j<s[i];j++){
            c=j;
            if(a==c || b==c)
                continue;
    //        cout<<a<<" "<<b<<" "<<c<<" "<<i<<" "<<endl;
            res+=calc(a,b,s.size()-1-i);
        }
        if(i>0 && s[i]==s[i-1])
            break;
        if(i>1 && s[i]==s[i-2])
            break;
        if(i==s.size()-1)
            res++;
    }    
    return res;
}
int main(){
    #ifdef LOCAL
        freopen ("test.in", "r", stdin);
    #endif                                     
    cin>>a>>b;   
    if(a<10){
        bv=tov(b);
        cout<<get(bv);
        return 0;
    }                    
    av=tov(a-1);
    bv=tov(b);
    cout<<get(bv)-get(av);
}

Compilation message

numbers.cpp: In function 'long long int get(std::vector<int>)':
numbers.cpp:41:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<s.size();i++){
                 ~^~~~~~~~~
numbers.cpp:59:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(i==s.size()-1)
            ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 488 KB Output isn't correct
3 Correct 2 ms 600 KB Output is correct
4 Incorrect 2 ms 712 KB Output isn't correct
5 Correct 2 ms 712 KB Output is correct
6 Incorrect 2 ms 744 KB Output isn't correct
7 Incorrect 2 ms 744 KB Output isn't correct
8 Incorrect 2 ms 744 KB Output isn't correct
9 Correct 3 ms 796 KB Output is correct
10 Correct 3 ms 796 KB Output is correct
11 Correct 3 ms 796 KB Output is correct
12 Correct 1 ms 840 KB Output is correct
13 Correct 3 ms 840 KB Output is correct
14 Incorrect 3 ms 840 KB Output isn't correct
15 Incorrect 3 ms 840 KB Output isn't correct
16 Correct 3 ms 840 KB Output is correct
17 Correct 2 ms 840 KB Output is correct
18 Incorrect 4 ms 840 KB Output isn't correct
19 Correct 2 ms 840 KB Output is correct
20 Incorrect 3 ms 916 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 916 KB Output is correct
2 Correct 3 ms 916 KB Output is correct
3 Correct 2 ms 916 KB Output is correct
4 Correct 3 ms 916 KB Output is correct
5 Incorrect 3 ms 916 KB Output isn't correct
6 Correct 3 ms 916 KB Output is correct
7 Incorrect 3 ms 916 KB Output isn't correct
8 Incorrect 2 ms 916 KB Output isn't correct
9 Incorrect 3 ms 916 KB Output isn't correct
10 Incorrect 2 ms 964 KB Output isn't correct
11 Correct 3 ms 964 KB Output is correct
12 Incorrect 3 ms 964 KB Output isn't correct
13 Incorrect 3 ms 964 KB Output isn't correct
14 Incorrect 2 ms 980 KB Output isn't correct
15 Incorrect 3 ms 980 KB Output isn't correct
16 Correct 4 ms 980 KB Output is correct
17 Correct 2 ms 980 KB Output is correct
18 Correct 2 ms 980 KB Output is correct
19 Correct 2 ms 980 KB Output is correct
20 Correct 2 ms 1024 KB Output is correct
21 Correct 3 ms 1024 KB Output is correct
22 Correct 2 ms 1024 KB Output is correct
23 Correct 2 ms 1024 KB Output is correct
24 Correct 3 ms 1024 KB Output is correct
25 Correct 2 ms 1024 KB Output is correct
26 Correct 2 ms 1024 KB Output is correct
27 Correct 2 ms 1048 KB Output is correct
28 Correct 3 ms 1048 KB Output is correct
29 Correct 2 ms 1048 KB Output is correct
30 Correct 3 ms 1048 KB Output is correct
31 Correct 2 ms 1048 KB Output is correct
32 Correct 2 ms 1048 KB Output is correct
33 Correct 2 ms 1048 KB Output is correct
34 Correct 3 ms 1048 KB Output is correct
35 Correct 2 ms 1048 KB Output is correct
36 Correct 2 ms 1048 KB Output is correct
37 Correct 2 ms 1048 KB Output is correct
38 Correct 2 ms 1048 KB Output is correct
39 Correct 3 ms 1048 KB Output is correct
40 Correct 3 ms 1048 KB Output is correct
41 Correct 2 ms 1048 KB Output is correct
42 Correct 4 ms 1048 KB Output is correct
43 Correct 2 ms 1048 KB Output is correct
44 Correct 3 ms 1048 KB Output is correct
45 Correct 3 ms 1048 KB Output is correct