답안 #1120220

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1120220 2024-11-28T06:35:46 Z vjudge1 Palindrome-Free Numbers (BOI13_numbers) C++17
12.5 / 100
1000 ms 512 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

const int sz=2e5+5;

const int INF=1e18;

const int MOD=1e9+7;

bool check(string s)
{
    //cout<<s<<endl;
    
    if(s.size()<4)
    {
        if(s.size()==1)
            return true;
        
        if(s.size()==2)
            return (s[0]!=s[1]);
        
        return (s[0]!=s[2] && s[1]!=s[2] && s[0]!=s[1]);
    }
    
    for(int i=0;i<s.size()-4;i++)
        if((s[i]==s[i+3] && s[i+1]==s[i+2]) || (s[i]==s[i+2] && s[i]!=s[i+3]) || (s[i]!=s[i+3] && s[i+1]==s[i+3]) || (s[i]==s[i+1] || s[i+1]==s[i+2] || s[i+2]==s[i+3]))
            return false;
    
    return true;
}

void solve()
{
    int a,b,res=0;
    
    cin>>a>>b;
    
    for(int i=a;i<=b;i++)
    {
        string s=to_string(i);
        
        if(check(s))
            res++;
    }
    
    cout<<res;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
}

Compilation message

numbers.cpp: In function 'bool check(std::string)':
numbers.cpp:28:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i=0;i<s.size()-4;i++)
      |                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 7 ms 452 KB Output isn't correct
4 Incorrect 3 ms 456 KB Output isn't correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Incorrect 1 ms 336 KB Output isn't correct
12 Incorrect 1 ms 336 KB Output isn't correct
13 Correct 1 ms 336 KB Output is correct
14 Incorrect 4 ms 336 KB Output isn't correct
15 Incorrect 3 ms 336 KB Output isn't correct
16 Incorrect 1 ms 336 KB Output isn't correct
17 Incorrect 1 ms 336 KB Output isn't correct
18 Correct 1 ms 336 KB Output is correct
19 Incorrect 8 ms 456 KB Output isn't correct
20 Incorrect 3 ms 336 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 199 ms 440 KB Output isn't correct
2 Execution timed out 1057 ms 336 KB Time limit exceeded
3 Execution timed out 1060 ms 336 KB Time limit exceeded
4 Execution timed out 1047 ms 336 KB Time limit exceeded
5 Execution timed out 1055 ms 336 KB Time limit exceeded
6 Execution timed out 1062 ms 336 KB Time limit exceeded
7 Incorrect 91 ms 336 KB Output isn't correct
8 Incorrect 50 ms 512 KB Output isn't correct
9 Incorrect 109 ms 336 KB Output isn't correct
10 Incorrect 122 ms 336 KB Output isn't correct
11 Incorrect 209 ms 336 KB Output isn't correct
12 Execution timed out 1035 ms 336 KB Time limit exceeded
13 Incorrect 229 ms 336 KB Output isn't correct
14 Execution timed out 1062 ms 336 KB Time limit exceeded
15 Execution timed out 1068 ms 336 KB Time limit exceeded
16 Execution timed out 1059 ms 336 KB Time limit exceeded
17 Execution timed out 1052 ms 336 KB Time limit exceeded
18 Execution timed out 1057 ms 336 KB Time limit exceeded
19 Execution timed out 1070 ms 336 KB Time limit exceeded
20 Execution timed out 1069 ms 336 KB Time limit exceeded
21 Execution timed out 1061 ms 336 KB Time limit exceeded
22 Execution timed out 1051 ms 336 KB Time limit exceeded
23 Execution timed out 1059 ms 336 KB Time limit exceeded
24 Execution timed out 1049 ms 336 KB Time limit exceeded
25 Execution timed out 1084 ms 336 KB Time limit exceeded
26 Execution timed out 1085 ms 404 KB Time limit exceeded
27 Execution timed out 1046 ms 504 KB Time limit exceeded
28 Execution timed out 1064 ms 336 KB Time limit exceeded
29 Execution timed out 1052 ms 336 KB Time limit exceeded
30 Execution timed out 1050 ms 512 KB Time limit exceeded
31 Execution timed out 1035 ms 336 KB Time limit exceeded
32 Execution timed out 1035 ms 336 KB Time limit exceeded
33 Execution timed out 1071 ms 336 KB Time limit exceeded
34 Execution timed out 1041 ms 336 KB Time limit exceeded
35 Execution timed out 1053 ms 336 KB Time limit exceeded
36 Execution timed out 1067 ms 336 KB Time limit exceeded
37 Execution timed out 1065 ms 336 KB Time limit exceeded
38 Execution timed out 1022 ms 336 KB Time limit exceeded
39 Execution timed out 1057 ms 336 KB Time limit exceeded
40 Execution timed out 1062 ms 336 KB Time limit exceeded
41 Execution timed out 1035 ms 336 KB Time limit exceeded
42 Execution timed out 1053 ms 512 KB Time limit exceeded
43 Execution timed out 1038 ms 336 KB Time limit exceeded
44 Execution timed out 1062 ms 336 KB Time limit exceeded
45 Execution timed out 1052 ms 336 KB Time limit exceeded