답안 #1080352

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080352 2024-08-29T09:02:32 Z aletra Palindrome-Free Numbers (BOI13_numbers) C++14
38.3333 / 100
1000 ms 600 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

bool has_palindrome(ll num){
    string s = to_string(num);
    ll n = s.size();
    if (n == 1)
        return 0;
    
    if (n == 2){
        if (s[0] == s[1])
            return 1;
        else
            return 0;
    }
    if (s[0] == s[1])
        return 1;

    ll prev = s[0];
    ll prevprev = s[1];
    rep(i,2,n){
        if (s[i] == prev){
            return 1;
        }
        else
            prev = s[i];
        if (s[i] == prevprev){
            return 1;
        }
        else
            prevprev = s[i-1];
    }
    return 0;
}

ll calc(ll A, ll B){
    ll cnt =0;
    rep(i,A,B+1){
        //cout << i << " " << has_palindrome(i) << "\n";
        if (!has_palindrome(i))
            cnt += 1;
    }

    
    return cnt;
}


int main(){
    cin.tie(0)->sync_with_stdio(0);
    ll A, B; cin >> A>> B;
    cout << calc(A,B) << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 5 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 456 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 5 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 162 ms 344 KB Output is correct
2 Execution timed out 1047 ms 344 KB Time limit exceeded
3 Execution timed out 1063 ms 348 KB Time limit exceeded
4 Execution timed out 1048 ms 348 KB Time limit exceeded
5 Execution timed out 1008 ms 344 KB Time limit exceeded
6 Execution timed out 1036 ms 348 KB Time limit exceeded
7 Correct 61 ms 344 KB Output is correct
8 Correct 45 ms 348 KB Output is correct
9 Correct 84 ms 600 KB Output is correct
10 Correct 108 ms 596 KB Output is correct
11 Correct 167 ms 436 KB Output is correct
12 Correct 819 ms 432 KB Output is correct
13 Correct 174 ms 432 KB Output is correct
14 Execution timed out 1064 ms 348 KB Time limit exceeded
15 Execution timed out 1058 ms 348 KB Time limit exceeded
16 Execution timed out 1054 ms 348 KB Time limit exceeded
17 Execution timed out 1071 ms 348 KB Time limit exceeded
18 Execution timed out 1039 ms 344 KB Time limit exceeded
19 Execution timed out 1069 ms 348 KB Time limit exceeded
20 Execution timed out 1054 ms 348 KB Time limit exceeded
21 Execution timed out 1071 ms 348 KB Time limit exceeded
22 Execution timed out 1059 ms 348 KB Time limit exceeded
23 Execution timed out 1029 ms 344 KB Time limit exceeded
24 Execution timed out 1058 ms 348 KB Time limit exceeded
25 Execution timed out 1051 ms 348 KB Time limit exceeded
26 Execution timed out 1033 ms 344 KB Time limit exceeded
27 Execution timed out 1012 ms 344 KB Time limit exceeded
28 Execution timed out 1066 ms 348 KB Time limit exceeded
29 Execution timed out 1062 ms 348 KB Time limit exceeded
30 Execution timed out 1045 ms 344 KB Time limit exceeded
31 Execution timed out 1063 ms 348 KB Time limit exceeded
32 Execution timed out 1032 ms 348 KB Time limit exceeded
33 Execution timed out 1070 ms 344 KB Time limit exceeded
34 Execution timed out 1078 ms 348 KB Time limit exceeded
35 Execution timed out 1048 ms 344 KB Time limit exceeded
36 Execution timed out 1073 ms 348 KB Time limit exceeded
37 Execution timed out 1063 ms 348 KB Time limit exceeded
38 Execution timed out 1066 ms 348 KB Time limit exceeded
39 Execution timed out 1066 ms 348 KB Time limit exceeded
40 Execution timed out 1012 ms 344 KB Time limit exceeded
41 Execution timed out 1063 ms 348 KB Time limit exceeded
42 Execution timed out 1028 ms 344 KB Time limit exceeded
43 Execution timed out 1042 ms 344 KB Time limit exceeded
44 Execution timed out 1055 ms 348 KB Time limit exceeded
45 Execution timed out 1058 ms 348 KB Time limit exceeded