Submission #771131

# Submission time Handle Problem Language Result Execution time Memory
771131 2023-07-02T13:21:10 Z pogson Crossing (JOI21_crossing) C++17
0 / 100
258 ms 724 KB
#include <bits/stdc++.h>

struct ter {
    ter(const std::string& seqq) {
        seq = "";
        for (int i = 0; i < (int)seqq.size(); ++i) {
            char q = seqq[i];
            int dig = 1;
            if (q == 'O') {
                dig = 0;
            }
            else if (q == 'I') {
                dig = 2;
            }
            seq += '0' + dig;
        }
        
    }
    ter operator *(int a) {
        ter temp = *this;
        for (int i = 0; i < (int)seq.size(); ++i) {
            int dig = temp.seq[i] - '0';
            dig *= a;
            dig %= 3;
            temp.seq[i] = '0' + dig;
        }
        return temp;
    }
    ter operator +(const ter& a) {
        ter temp = *this;
        for (int i = 0; i < (int)seq.size(); ++i) {
            int dig = temp.seq[i] + a.seq[i] - 2 * '0';
            dig %= 3;
            temp.seq[i] = '0' + dig;
        }
        return temp;
    }
    std::string seq;
};



int main() {

    std::string a, b, c;
    std::set<std::string> all;
    int n;
    std::cin >> n;
    std::cin >> a >> b >> c;
    ter aa(a), bb(b), cc(c);
    all.insert({ aa.seq, bb.seq, cc.seq, ((aa + bb) * 2).seq, ((aa + cc) * 2).seq, ((cc + bb) * 2).seq });
    all.insert({ (aa + bb + cc*2).seq, (aa + cc + bb * 2).seq, (cc + bb + aa * 2).seq });
    //std::cout << "ALL POSSIBLE ANSWERES ARE" << std::endl;
    //for (const auto& s : all) {
    //    std::cout << s << std::endl;
    //}
    //std::cout << "#####" << std::endl;
    int q;
    std::cin >> q;
    std::string s;
    std::cin >> s;
    std::cout << /*"S is obtainable? " << */ ((all.find(ter(s).seq) == all.end()) ? "NO" : "YES") << std::endl;
    while (q--) {
        int l, r;
        std::cin >> l >> r;
        char q;
        std::cin >> q;
        int dig = 1;
        if (q == 'O') {
            dig = 0;
        }
        else if (q == 'I'){
            dig = 2;
        }
        for (int i = l - 1; i < r; ++i) {
            s[i] = dig + '0';
        }
        //std::cout << "S is " << s << std::endl;
        std::cout << /*"S is obtainable? " << */ ((all.find(s) == all.end()) ? "NO" : "YES") << std::endl;
    }
    //ter a{ "1010" };
    //ter b{ "2010" };
    //std::cout << (a * 2).seq << std::endl;
    //std::cout << (a + b).seq << std::endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 258 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 258 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 258 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 258 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -