답안 #526271

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
526271 2022-02-14T06:37:11 Z Carmel_Ab1 Palindrome-Free Numbers (BOI13_numbers) C++17
25 / 100
12 ms 316 KB
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 */
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int>vi;
typedef vector<vector<int>>vvi;
typedef vector<ll>vl;
typedef vector<vl> vvl;
typedef pair<int,int>pi;
typedef pair<ll,ll> pl;
typedef vector<pl> vpl;
typedef vector<ld> vld;
typedef pair<ld,ld> pld;
typedef vector<pi> vpi;

//typedef tree<ll, null_type, less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<typename T> ostream& operator<<(ostream& os, vector<T>& a){os<<"[";for(int i=0; i<ll(a.size()); i++){os << a[i] << ((i!=ll(a.size()-1)?" ":""));}os << "]\n"; return os;}

#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define outfl(x){cout << x << endl;return;}
#define GLHF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define print(x){for(auto ait:x) cout << ait << " "; cout << "\n";}
#define pb push_back
#define umap unordered_map

template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1, T2>& p){is >> p.first >> p.second;return is;}
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2>& p){os <<"" << p.first << " " << p.second << ""; return os;}
void usaco(string taskname){
    string fin = taskname + ".in";
    string fout = taskname + ".out";
    const char* FIN = fin.c_str();
    const char* FOUT = fout.c_str();
    freopen(FIN, "r", stdin);
    freopen(FOUT, "w", stdout);
}
template<typename T>
void read(vector<T>& v){
    int n=v.size();
    for(int i=0; i<n; i++)
        cin >> v[i];
}
template<typename T>
vector<T>UNQ(vector<T>a){
    vector<T>ans;
    for(T t:a)
        if(ans.empty() || t!=ans.back())
            ans.push_back(t);
    return ans;
}



void solve();
int main(){
    GLHF;
    int t=1;
    //cin >> t;
    while(t--)
        solve();
}
void solve() {
    ll l,r;
    cin >> l >> r;

    if(r-l+1<=1e6){
        ll ans=0;
        for(ll i=l; i<=r; i++){
            string s=to_string(i);
            bool ok=1;
            for(int j=0; j+1<s.size(); j++) {
                if(s[j]==s[j+1])
                    ok=0;
                if(s[j]==s[j+2] && j+2<s.size())
                    ok=0;
            }
            if(ok)
                ans++;
        }
        out(ans)
    }
    out(r/11 - (l-1)/11)
}

Compilation message

numbers.cpp: In function 'void solve()':
numbers.cpp:84:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |             for(int j=0; j+1<s.size(); j++) {
      |                          ~~~^~~~~~~~~
numbers.cpp:87:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |                 if(s[j]==s[j+2] && j+2<s.size())
      |                                    ~~~^~~~~~~~~
numbers.cpp: In function 'void usaco(std::string)':
numbers.cpp:47:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |     freopen(FIN, "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~
numbers.cpp:48:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |     freopen(FOUT, "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 8 ms 316 KB Output is correct
4 Correct 2 ms 308 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 312 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 12 ms 296 KB Output is correct
20 Correct 3 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 308 KB Output isn't correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Incorrect 1 ms 312 KB Output isn't correct
4 Incorrect 0 ms 304 KB Output isn't correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Incorrect 0 ms 312 KB Output isn't correct
7 Incorrect 0 ms 312 KB Output isn't correct
8 Incorrect 0 ms 204 KB Output isn't correct
9 Incorrect 1 ms 316 KB Output isn't correct
10 Incorrect 0 ms 316 KB Output isn't correct
11 Incorrect 0 ms 204 KB Output isn't correct
12 Incorrect 1 ms 312 KB Output isn't correct
13 Incorrect 1 ms 204 KB Output isn't correct
14 Incorrect 0 ms 204 KB Output isn't correct
15 Incorrect 1 ms 304 KB Output isn't correct
16 Incorrect 1 ms 316 KB Output isn't correct
17 Incorrect 1 ms 312 KB Output isn't correct
18 Incorrect 0 ms 308 KB Output isn't correct
19 Incorrect 1 ms 204 KB Output isn't correct
20 Incorrect 0 ms 204 KB Output isn't correct
21 Incorrect 1 ms 204 KB Output isn't correct
22 Incorrect 1 ms 204 KB Output isn't correct
23 Incorrect 0 ms 204 KB Output isn't correct
24 Incorrect 0 ms 204 KB Output isn't correct
25 Incorrect 0 ms 204 KB Output isn't correct
26 Incorrect 1 ms 204 KB Output isn't correct
27 Incorrect 0 ms 204 KB Output isn't correct
28 Incorrect 1 ms 204 KB Output isn't correct
29 Incorrect 1 ms 204 KB Output isn't correct
30 Incorrect 1 ms 204 KB Output isn't correct
31 Incorrect 1 ms 312 KB Output isn't correct
32 Incorrect 0 ms 204 KB Output isn't correct
33 Incorrect 0 ms 204 KB Output isn't correct
34 Incorrect 1 ms 204 KB Output isn't correct
35 Incorrect 1 ms 204 KB Output isn't correct
36 Incorrect 1 ms 204 KB Output isn't correct
37 Incorrect 1 ms 204 KB Output isn't correct
38 Incorrect 1 ms 312 KB Output isn't correct
39 Incorrect 1 ms 204 KB Output isn't correct
40 Incorrect 1 ms 204 KB Output isn't correct
41 Incorrect 0 ms 204 KB Output isn't correct
42 Incorrect 1 ms 204 KB Output isn't correct
43 Incorrect 1 ms 204 KB Output isn't correct
44 Incorrect 0 ms 204 KB Output isn't correct
45 Incorrect 0 ms 204 KB Output isn't correct