Submission #48467

# Submission time Handle Problem Language Result Execution time Memory
48467 2018-05-13T18:18:50 Z rkocharyan Palindrome-Free Numbers (BOI13_numbers) C++14
22.5 / 100
1000 ms 648 KB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <bitset>
#include <iomanip>
#include <memory>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <climits>
#include <cassert>
using namespace std;

#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define mp make_pair
#define add push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mem(a,b) memset(a, b, sizeof(a))
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:20000007")
#pragma GCC optimize("unroll-loops")

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef vector <int> lnum;

const int N = (int)1e6 + 100;
const int maxn = (int)1e3 + 100;
const int base = (int)1e9;
const int mod = (int)1e9 + 7;
const int inf = INT_MAX;
const long long ll_inf = LLONG_MAX;
const long double PI = acos((long double)-1.0);
const long double eps = 1e-8;

void solve() {
	long long l, r; cin >> l >> r;
	long long ans = 0;
	for (long long i = l; i <= r; ++i) {
		string now = to_string(i);
		bool pal2, pal3;
		pal2 = pal3 = 1;
		for (int j = 0; j < now.size() - 1; ++j) if (now[j] == now[j + 1]) {
			pal2 = 0;
			break;
		}
		for (int j = 0; j < now.size() - 2; ++j) if (now[j] == now[j + 2]) {
			pal3 = 0;
			break;
		}
		ans += (pal2 & pal3);
	}
	cout << ans << '\n';
}

int main() {
	//ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

	//#define Freopen
#ifdef Freopen
#ifndef _MSC_VER 
#define TASK ""
	freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);
#endif
#endif

	int T = 1;
	//scanf("%d", &T);

	for (; T; --T) solve();

#ifdef DEBUG
	cerr << double(1.0 * clock() / CLOCKS_PER_SEC) << '\n';
#endif 

	return 0;
}

Compilation message

numbers.cpp:34:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 
numbers.cpp:35:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/STACK:20000007")
 
numbers.cpp: In function 'void solve()':
numbers.cpp:61:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < now.size() - 1; ++j) if (now[j] == now[j + 1]) {
                   ~~^~~~~~~~~~~~~~~~
numbers.cpp:65:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < now.size() - 2; ++j) if (now[j] == now[j + 2]) {
                   ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Incorrect 2 ms 484 KB Output isn't correct
3 Correct 21 ms 484 KB Output is correct
4 Incorrect 12 ms 588 KB Output isn't correct
5 Incorrect 2 ms 588 KB Output isn't correct
6 Incorrect 2 ms 588 KB Output isn't correct
7 Incorrect 2 ms 588 KB Output isn't correct
8 Incorrect 2 ms 588 KB Output isn't correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 2 ms 588 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Incorrect 13 ms 596 KB Output isn't correct
15 Incorrect 13 ms 596 KB Output isn't correct
16 Correct 2 ms 620 KB Output is correct
17 Correct 5 ms 620 KB Output is correct
18 Incorrect 2 ms 620 KB Output isn't correct
19 Correct 21 ms 620 KB Output is correct
20 Correct 13 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 825 ms 620 KB Output is correct
2 Execution timed out 1073 ms 620 KB Time limit exceeded
3 Execution timed out 1079 ms 620 KB Time limit exceeded
4 Execution timed out 1090 ms 620 KB Time limit exceeded
5 Execution timed out 1087 ms 648 KB Time limit exceeded
6 Execution timed out 1084 ms 648 KB Time limit exceeded
7 Correct 375 ms 648 KB Output is correct
8 Correct 270 ms 648 KB Output is correct
9 Correct 530 ms 648 KB Output is correct
10 Correct 661 ms 648 KB Output is correct
11 Correct 816 ms 648 KB Output is correct
12 Execution timed out 1088 ms 648 KB Time limit exceeded
13 Execution timed out 1066 ms 648 KB Time limit exceeded
14 Execution timed out 1093 ms 648 KB Time limit exceeded
15 Execution timed out 1092 ms 648 KB Time limit exceeded
16 Execution timed out 1092 ms 648 KB Time limit exceeded
17 Execution timed out 1075 ms 648 KB Time limit exceeded
18 Execution timed out 1091 ms 648 KB Time limit exceeded
19 Execution timed out 1088 ms 648 KB Time limit exceeded
20 Execution timed out 1092 ms 648 KB Time limit exceeded
21 Execution timed out 1084 ms 648 KB Time limit exceeded
22 Execution timed out 1083 ms 648 KB Time limit exceeded
23 Execution timed out 1079 ms 648 KB Time limit exceeded
24 Execution timed out 1085 ms 648 KB Time limit exceeded
25 Execution timed out 1081 ms 648 KB Time limit exceeded
26 Execution timed out 1069 ms 648 KB Time limit exceeded
27 Execution timed out 1088 ms 648 KB Time limit exceeded
28 Execution timed out 1085 ms 648 KB Time limit exceeded
29 Execution timed out 1087 ms 648 KB Time limit exceeded
30 Execution timed out 1085 ms 648 KB Time limit exceeded
31 Execution timed out 1076 ms 648 KB Time limit exceeded
32 Execution timed out 1081 ms 648 KB Time limit exceeded
33 Execution timed out 1081 ms 648 KB Time limit exceeded
34 Execution timed out 1082 ms 648 KB Time limit exceeded
35 Execution timed out 1076 ms 648 KB Time limit exceeded
36 Execution timed out 1084 ms 648 KB Time limit exceeded
37 Execution timed out 1081 ms 648 KB Time limit exceeded
38 Execution timed out 1084 ms 648 KB Time limit exceeded
39 Execution timed out 1082 ms 648 KB Time limit exceeded
40 Execution timed out 1079 ms 648 KB Time limit exceeded
41 Execution timed out 1083 ms 648 KB Time limit exceeded
42 Execution timed out 1088 ms 648 KB Time limit exceeded
43 Execution timed out 1080 ms 648 KB Time limit exceeded
44 Execution timed out 1089 ms 648 KB Time limit exceeded
45 Execution timed out 1090 ms 648 KB Time limit exceeded