답안 #448461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
448461 2021-07-30T08:33:48 Z fuad27 Palindrome-Free Numbers (BOI13_numbers) C++14
40.4167 / 100
1000 ms 296 KB
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define f first
#define s second
#define DEBUG(a, b) cerr<<a<<b;
pair<long long, bool> check(long long s) {
	long long prev = -1, pprev = -2;
	long long c = 1, n = 0, k = 0;
	while(s > 0) {
		if(s%10 == prev)return {n%(c/10) + 1, 1};
		else if(s%10 == pprev)return {n%(c/100)+1, 1};
		pprev = prev;
		prev = s%10;
		n+=s%10 * c;
		s/=10;
		c*=10;
	}
	return {1, 0};
}
int main () {
	long long a, b, c = 0;
	cin >> a >> b;
	long long k = b-a;
	while(b >= a) {
		pair<long long, bool> k = check(b);
		if(k.s)c+=k.f;
		b-=k.f;
	}
	cout<<k - c+1;
}

Compilation message

numbers.cpp: In function 'std::pair<long long int, bool> check(long long int)':
numbers.cpp:10:26: warning: unused variable 'k' [-Wunused-variable]
   10 |  long long c = 1, n = 0, k = 0;
      |                          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 3 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Incorrect 0 ms 204 KB Output isn't correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 3 ms 204 KB Output is correct
20 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 204 KB Output is correct
2 Execution timed out 1086 ms 204 KB Time limit exceeded
3 Execution timed out 1097 ms 204 KB Time limit exceeded
4 Execution timed out 1092 ms 204 KB Time limit exceeded
5 Correct 726 ms 264 KB Output is correct
6 Correct 746 ms 264 KB Output is correct
7 Correct 38 ms 204 KB Output is correct
8 Incorrect 27 ms 296 KB Output isn't correct
9 Correct 49 ms 268 KB Output is correct
10 Correct 64 ms 204 KB Output is correct
11 Correct 76 ms 204 KB Output is correct
12 Correct 418 ms 264 KB Output is correct
13 Correct 99 ms 268 KB Output is correct
14 Correct 724 ms 268 KB Output is correct
15 Incorrect 846 ms 204 KB Output isn't correct
16 Execution timed out 1094 ms 204 KB Time limit exceeded
17 Incorrect 0 ms 204 KB Output isn't correct
18 Incorrect 0 ms 204 KB Output isn't correct
19 Incorrect 0 ms 204 KB Output isn't correct
20 Incorrect 0 ms 204 KB Output isn't correct
21 Execution timed out 1099 ms 204 KB Time limit exceeded
22 Incorrect 0 ms 204 KB Output isn't correct
23 Execution timed out 1087 ms 204 KB Time limit exceeded
24 Incorrect 0 ms 204 KB Output isn't correct
25 Execution timed out 1088 ms 204 KB Time limit exceeded
26 Execution timed out 1096 ms 204 KB Time limit exceeded
27 Execution timed out 1094 ms 204 KB Time limit exceeded
28 Execution timed out 1097 ms 204 KB Time limit exceeded
29 Incorrect 0 ms 204 KB Output isn't correct
30 Incorrect 0 ms 204 KB Output isn't correct
31 Execution timed out 1092 ms 204 KB Time limit exceeded
32 Incorrect 1 ms 204 KB Output isn't correct
33 Execution timed out 1093 ms 204 KB Time limit exceeded
34 Incorrect 0 ms 204 KB Output isn't correct
35 Execution timed out 1092 ms 204 KB Time limit exceeded
36 Execution timed out 1084 ms 204 KB Time limit exceeded
37 Execution timed out 1100 ms 204 KB Time limit exceeded
38 Execution timed out 1093 ms 204 KB Time limit exceeded
39 Execution timed out 1087 ms 204 KB Time limit exceeded
40 Incorrect 1 ms 204 KB Output isn't correct
41 Execution timed out 1084 ms 204 KB Time limit exceeded
42 Incorrect 0 ms 204 KB Output isn't correct
43 Execution timed out 1095 ms 204 KB Time limit exceeded
44 Execution timed out 1076 ms 204 KB Time limit exceeded
45 Execution timed out 1094 ms 204 KB Time limit exceeded