codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1379.md (3021B)


      1 Source: https://codeforces.com/blog/entry/80216
      2 
      3 Thanks for the participation!
      4 
      5 [1379A - Acacius and String](/contest/1379/problem/A "Codeforces Round 657 (Div. 2)") was authored by [ch_egor](/profile/ch_egor "International Grandmaster ch_egor"), [meshanya](/profile/meshanya "Grandmaster meshanya") and prepared by [ch_egor](/profile/ch_egor "International Grandmaster ch_egor"), [vintage_Vlad_Makeev](/profile/vintage_Vlad_Makeev "International Grandmaster vintage_Vlad_Makeev")
      6 
      7 [1379B - Dubious Cyrpto](/contest/1379/problem/B "Codeforces Round 657 (Div. 2)") was authored by jury and prepared by [DebNatkh](/profile/DebNatkh "Candidate Master DebNatkh")
      8 
      9 [1379C - Choosing flowers](/contest/1379/problem/C "Codeforces Round 657 (Div. 2)") was authored and prepared by [grphil](/profile/grphil "Master grphil")
     10 
     11 [1379D - New Passenger Trams](/contest/1379/problem/D "Codeforces Round 657 (Div. 2)") was authored by Helen Andreeva and prepared by [KiKoS](/profile/KiKoS "Master KiKoS")
     12 
     13 [1379E - Inverse Genealogy](/contest/1379/problem/E "Codeforces Round 657 (Div. 2)") was authored and prepared by [voidmax](/profile/voidmax "International Grandmaster voidmax") and [I_love_myself](/profile/I_love_myself "Master I_love_myself")
     14 
     15 [1379F2 - Chess Strikes Back (hard version)](/contest/1379/problem/F2 "Codeforces Round 657 (Div. 2)") was authored by [300iq](/profile/300iq "Legendary Grandmaster 300iq") and prepared by [isaf27](/profile/isaf27 "Grandmaster isaf27")
     16 
     17 Tutorial is loading...
     18 
     19 **vintage_Vlad_Makeev code**
     20 
     21 ```
     22 #include <bits/stdc++.h>
     23 
     24 using ll = long long;
     25 using ld = long double;
     26 using ull = unsigned long long;
     27 
     28 using namespace std;
     29 
     30 const string T = "abacaba";
     31 
     32 int count(const string& s) {
     33     int cnt = 0;
     34     for (int i = 0; i < (int)s.size(); ++i) {
     35         if (s.substr(i, T.size()) == T) {
     36             ++cnt;
     37         }
     38     }
     39 
     40     return cnt;
     41 }
     42 
     43 int main() {
     44     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
     45     int t;
     46     cin >> t;
     47     for (int tt = 1; tt <= t; ++tt) {
     48         int n;
     49         cin >> n;
     50         string s;
     51         cin >> s;
     52         bool F = false;
     53 
     54         for (int i = 0; i + T.size() <= n; ++i) {
     55             string ss = s;
     56             bool ok = true;
     57             for (int j = 0; j < T.size(); j++) {
     58                 if (ss[i + j] != '?' && ss[i + j] != T[j]) {
     59                     ok = false;
     60                     break;
     61                 }
     62                 ss[i + j] = T[j];
     63             }
     64             if (ok && count(ss) == 1) {
     65                 for (int j = 0; j < n; j++) {
     66                     if (ss[j] == '?') {
     67                         ss[j] = 'd';
     68                     }
     69                 }
     70                 F = true;
     71                 cout << "Yes\n";
     72                 cout << ss << "\n";
     73                 break;
     74             }
     75         }
     76         if (!F) {
     77             cout << "No\n";
     78         }
     79     }
     80 
     81     return 0;
     82 }
     83 ```
     84 
     85 Tutorial is loading...
     86 
     87 Tutorial is loading...
     88 
     89 Tutorial is loading...
     90 
     91 Tutorial is loading...
     92 
     93 Tutorial is loading...
     94 
     95 Tutorial is loading...