제출 #1120493

#제출 시각아이디문제언어결과실행 시간메모리
1120493vjudge1Palindrome-Free Numbers (BOI13_numbers)C++17
25.83 / 100
1097 ms512 KiB
#include <bits/stdc++.h>
using namespace std;
# define int long long
bool ok(string s)
{
  string scc;
  for(int i = 0; i < s.size() - 1; i++)
  {
    for(int j = i + 1; j < s.size(); j++)
    {
      string sc = "";
      for(int z = i; z <= j; z++) 
        sc += s[z];
      scc = sc;
      reverse(scc.begin(), scc.end());
      if(sc == scc){
        return 1;
      }
    }
  }
  return 0;
}

void solve()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  vector < string > v;
  set < string > npf;
  string s, sc;
  int a, b, cnt = 0, k;
  scanf("%d%d", &a, &b);
  for(int i = a; i <= b; i++)
  {
    s = to_string(i);
    if(ok(s))
    {
      cnt++;  
    }
  }
  printf("%d", (b - a + 1) - cnt);
}

signed main()
{
  int tt = 1;
  // cin >> tt;
  while(tt--)
    solve();
}

컴파일 시 표준 에러 (stderr) 메시지

numbers.cpp: In function 'bool ok(std::string)':
numbers.cpp:7:20: 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]
    7 |   for(int i = 0; i < s.size() - 1; i++)
      |                  ~~^~~~~~~~~~~~~~
numbers.cpp:9:26: 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]
    9 |     for(int j = i + 1; j < s.size(); j++)
      |                        ~~^~~~~~~~~~
numbers.cpp: In function 'void solve()':
numbers.cpp:33:11: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   33 |   scanf("%d%d", &a, &b);
      |          ~^     ~~
      |           |     |
      |           int*  long long int*
      |          %lld
numbers.cpp:33:13: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   33 |   scanf("%d%d", &a, &b);
      |            ~^       ~~
      |             |       |
      |             int*    long long int*
      |            %lld
numbers.cpp:42:12: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   42 |   printf("%d", (b - a + 1) - cnt);
      |           ~^   ~~~~~~~~~~~~~~~~~
      |            |               |
      |            int             long long int
      |           %lld
numbers.cpp:32:22: warning: unused variable 'k' [-Wunused-variable]
   32 |   int a, b, cnt = 0, k;
      |                      ^
numbers.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   scanf("%d%d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...