MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

Codeforces_problems/Telephone Number 1167A/solution.cpp:8–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6using namespace std;
7
8int main() {
9 // Number of test cases
10 int t;
11 cin >> t;
12 // For each test case
13 while (t--) {
14 // The length of string s
15 int n;
16 cin >> n;
17 // Contains the digits
18 string s;
19 cin >> s;
20 bool ok = false;
21 // If n is below 11 then it's impossible to make a telephone number
22 // Otherwise check if it's possible to make a telephone number
23 // by deleting digits until an '8' is placed on the right position
24 // and then deleting any digit until it's exactly 11 digits
25 if (n >= 11)
26 FORN(i, n-10) {
27 if (s[i] == '8') {
28 ok = true;
29 }
30 }
31 // If there is a sequence of operations, after which s becomes a telephone number
32 if (ok) cout << "YES" << endl;
33 else cout << "NO" << endl;
34 }
35 return 0;
36}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected