Submission #1015499

#TimeUsernameProblemLanguageResultExecution timeMemory
1015499daffuwuCrossing (JOI21_crossing)C++14
26 / 100
7092 ms5932 KiB
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

long long n, sz, q, l, r;
bool bad;
char ch;
string s[3], cs, t0;
vector<string> ls;
map<string, bool> ex;

char crot(char a, char b)
{
    if (a>b) swap(a, b);
    if (a == b) return a;
    if (a == 'I' && b == 'J') return 'O';
    if (a == 'I' && b == 'O') return 'J';
    return 'I';
}

string cross(string a, string b)
{
    int i;
    string c = "";
    for (i=0; i<n; i++)
    {
        c += crot(a[i], b[i]);
    }
    return c;
}

int main() 
{
    long long i, j, rr;
    scanf("%lld", &n);
    cin >> s[0] >> s[1] >> s[2];
    
    ex[s[0]] = ex[s[1]] = ex[s[2]] = 1;
    for (auto [ky, _]:ex) ls.push_back(ky);
    for (; 1;)
    {
        sz = ls.size();
        bad = 1;
        for (i=0; i<sz; i++)
        {
            for (j=i+1; j<sz; j++)
            {
                cs = cross(ls[i], ls[j]);
                if (!ex.count(cs))
                {
                    ex[cs] = 1;
                    bad = 0;
                    i = sz+1;
                    break;
                }
            }
        }
        if (bad) break;
        ls.push_back(cs);
    }
    // printf("terdapat %lld string:\n", (long long)ls.size());
    // for (auto el:ls)
    // {
    //     cout << el << "\n";
    // }
    // printf("crot\n");
    scanf("%lld", &q);
    for (rr=0; rr<=q; rr++)
    {
        if (rr == 0) cin >> t0;
        else 
        {
            scanf("%lld%lld %c", &l, &r, &ch);
            l--;
            r--;
            for (i=l; i<=r; i++) t0[i] = ch;
        }
        bad = 1;
        for (auto el:ls)
        {
            if (t0 == el) bad = 0;
        }
        if (bad) printf("No\n");
        else printf("Yes\n");
    }
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:41:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   41 |     for (auto [ky, _]:ex) ls.push_back(ky);
      |               ^
Main.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf("%lld", &n);
      |     ~~~~~^~~~~~~~~~~~
Main.cpp:69:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |     scanf("%lld", &q);
      |     ~~~~~^~~~~~~~~~~~
Main.cpp:75:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |             scanf("%lld%lld %c", &l, &r, &ch);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...