답안 #1120202

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1120202 2024-11-28T06:31:58 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]))
            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 504 KB Output is correct
3 Incorrect 7 ms 336 KB Output isn't correct
4 Incorrect 3 ms 336 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 2 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 4 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 512 KB Output is correct
19 Incorrect 10 ms 464 KB Output isn't correct
20 Incorrect 3 ms 336 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 148 ms 444 KB Output isn't correct
2 Execution timed out 1068 ms 336 KB Time limit exceeded
3 Execution timed out 1054 ms 336 KB Time limit exceeded
4 Execution timed out 1065 ms 336 KB Time limit exceeded
5 Execution timed out 1051 ms 336 KB Time limit exceeded
6 Execution timed out 1039 ms 336 KB Time limit exceeded
7 Incorrect 113 ms 336 KB Output isn't correct
8 Incorrect 56 ms 336 KB Output isn't correct
9 Incorrect 81 ms 336 KB Output isn't correct
10 Incorrect 129 ms 336 KB Output isn't correct
11 Incorrect 162 ms 336 KB Output isn't correct
12 Execution timed out 1054 ms 436 KB Time limit exceeded
13 Incorrect 174 ms 336 KB Output isn't correct
14 Execution timed out 1039 ms 336 KB Time limit exceeded
15 Execution timed out 1039 ms 336 KB Time limit exceeded
16 Execution timed out 1045 ms 336 KB Time limit exceeded
17 Execution timed out 1018 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 1057 ms 336 KB Time limit exceeded
21 Execution timed out 1053 ms 336 KB Time limit exceeded
22 Execution timed out 1070 ms 336 KB Time limit exceeded
23 Execution timed out 1081 ms 336 KB Time limit exceeded
24 Execution timed out 1088 ms 336 KB Time limit exceeded
25 Execution timed out 1085 ms 336 KB Time limit exceeded
26 Execution timed out 1066 ms 336 KB Time limit exceeded
27 Execution timed out 1083 ms 336 KB Time limit exceeded
28 Execution timed out 1076 ms 348 KB Time limit exceeded
29 Execution timed out 1054 ms 336 KB Time limit exceeded
30 Execution timed out 1051 ms 508 KB Time limit exceeded
31 Execution timed out 1054 ms 336 KB Time limit exceeded
32 Execution timed out 1087 ms 336 KB Time limit exceeded
33 Execution timed out 1084 ms 336 KB Time limit exceeded
34 Execution timed out 1084 ms 336 KB Time limit exceeded
35 Execution timed out 1083 ms 336 KB Time limit exceeded
36 Execution timed out 1061 ms 336 KB Time limit exceeded
37 Execution timed out 1067 ms 336 KB Time limit exceeded
38 Execution timed out 1041 ms 336 KB Time limit exceeded
39 Execution timed out 1067 ms 336 KB Time limit exceeded
40 Execution timed out 1048 ms 336 KB Time limit exceeded
41 Execution timed out 1063 ms 336 KB Time limit exceeded
42 Execution timed out 1051 ms 336 KB Time limit exceeded
43 Execution timed out 1039 ms 336 KB Time limit exceeded
44 Execution timed out 1066 ms 336 KB Time limit exceeded
45 Execution timed out 1040 ms 336 KB Time limit exceeded