-
Notifications
You must be signed in to change notification settings - Fork 0
/
Problem-B.cpp
55 lines (45 loc) · 1.8 KB
/
Problem-B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define pvar(x) std::cout << x << '\n'
#define pvars(x) std::cout << x << ' '
#define read(x) std::cin >> x
#define outprec(x) std::cout.precision(x)
#define unto(i, begin, end) for (int i = begin; i < end; ++i)
#define fea(last) unto(i, 0, last)
#define min3(a, b, c) std::min(std::min(a, b), c)
#define max3(a, b, c) std::max(std::max(a, b), c)
#define popcount(x) __builtin_popcount(x)
#define popcount_ll(x) __builtin_popcountll(x)
#define leading_zeros(x) __builtin_clz(x)
#define trailing_zeros(x) __builtin_ctz(x)
#define x2(n) (n << 1)
#define d2(n) (n >> 1)
template <typename T> T gcd(T a, T b) {return(b ? std::__gcd(a, b) : a);}
template <typename T> T lcm(T a, T b) {return(a * (b / gcd(a, b)));}
bool powerof2(int64_t n) {return (n && !(n & (n - 1)));}
bool between(int64_t number, int64_t begin, int64_t end) {return (number >= begin) && (number <= end);}
bool perfect_square(int64_t n) {return (floor(sqrt(n)) == ceil(sqrt(n)));}
int64_t square(int64_t n) {return n * n;}
int64_t mod(int64_t n, int64_t mod = 1000000007){return (n > mod) ? (n % mod) : n;}
int32_t main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
int tests_number;
read(tests_number);
while (tests_number--)
{
size_t string_length;
read(string_length);
std::string string;
read(string);
if (string.substr(0, 4) == "2020") pvar("YES");
else if (string.substr(0, 3) == "202" && string.substr(string_length - 1, 1) == "0") pvar("YES");
else if (string.substr(0, 2) == "20" && string.substr(string_length - 2, 2) == "20") pvar("YES");
else if (string.substr(0, 1) == "2" && string.substr(string_length - 3, 3) == "020") pvar("YES");
else if (string.substr(string_length - 4, 4) == "2020") pvar("YES");
else pvar("NO");
}
return 0;
}