Submission #771132

# Submission time Handle Problem Language Result Execution time Memory
771132 2023-07-02T13:22:15 Z pogson Crossing (JOI21_crossing) C++17
26 / 100
7000 ms 3508 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 Correct 256 ms 804 KB Output is correct
2 Correct 314 ms 976 KB Output is correct
3 Correct 285 ms 844 KB Output is correct
4 Correct 266 ms 752 KB Output is correct
5 Correct 276 ms 852 KB Output is correct
6 Correct 264 ms 788 KB Output is correct
7 Correct 282 ms 840 KB Output is correct
8 Correct 275 ms 856 KB Output is correct
9 Correct 276 ms 872 KB Output is correct
10 Correct 280 ms 848 KB Output is correct
11 Correct 276 ms 856 KB Output is correct
12 Correct 302 ms 796 KB Output is correct
13 Correct 279 ms 828 KB Output is correct
14 Correct 282 ms 852 KB Output is correct
15 Correct 275 ms 876 KB Output is correct
16 Correct 281 ms 768 KB Output is correct
17 Correct 277 ms 772 KB Output is correct
18 Correct 292 ms 900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 256 ms 804 KB Output is correct
2 Correct 314 ms 976 KB Output is correct
3 Correct 285 ms 844 KB Output is correct
4 Correct 266 ms 752 KB Output is correct
5 Correct 276 ms 852 KB Output is correct
6 Correct 264 ms 788 KB Output is correct
7 Correct 282 ms 840 KB Output is correct
8 Correct 275 ms 856 KB Output is correct
9 Correct 276 ms 872 KB Output is correct
10 Correct 280 ms 848 KB Output is correct
11 Correct 276 ms 856 KB Output is correct
12 Correct 302 ms 796 KB Output is correct
13 Correct 279 ms 828 KB Output is correct
14 Correct 282 ms 852 KB Output is correct
15 Correct 275 ms 876 KB Output is correct
16 Correct 281 ms 768 KB Output is correct
17 Correct 277 ms 772 KB Output is correct
18 Correct 292 ms 900 KB Output is correct
19 Correct 3475 ms 3508 KB Output is correct
20 Execution timed out 7076 ms 3508 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 256 ms 804 KB Output is correct
2 Correct 314 ms 976 KB Output is correct
3 Correct 285 ms 844 KB Output is correct
4 Correct 266 ms 752 KB Output is correct
5 Correct 276 ms 852 KB Output is correct
6 Correct 264 ms 788 KB Output is correct
7 Correct 282 ms 840 KB Output is correct
8 Correct 275 ms 856 KB Output is correct
9 Correct 276 ms 872 KB Output is correct
10 Correct 280 ms 848 KB Output is correct
11 Correct 276 ms 856 KB Output is correct
12 Correct 302 ms 796 KB Output is correct
13 Correct 279 ms 828 KB Output is correct
14 Correct 282 ms 852 KB Output is correct
15 Correct 275 ms 876 KB Output is correct
16 Correct 281 ms 768 KB Output is correct
17 Correct 277 ms 772 KB Output is correct
18 Correct 292 ms 900 KB Output is correct
19 Correct 285 ms 856 KB Output is correct
20 Correct 288 ms 844 KB Output is correct
21 Correct 273 ms 856 KB Output is correct
22 Correct 254 ms 2108 KB Output is correct
23 Correct 279 ms 2392 KB Output is correct
24 Correct 277 ms 2244 KB Output is correct
25 Correct 280 ms 2380 KB Output is correct
26 Correct 267 ms 2248 KB Output is correct
27 Correct 282 ms 2380 KB Output is correct
28 Correct 270 ms 2152 KB Output is correct
29 Correct 286 ms 2456 KB Output is correct
30 Correct 257 ms 2228 KB Output is correct
31 Correct 288 ms 2376 KB Output is correct
32 Correct 284 ms 2372 KB Output is correct
33 Correct 279 ms 2380 KB Output is correct
34 Correct 261 ms 2240 KB Output is correct
35 Correct 286 ms 2396 KB Output is correct
36 Correct 289 ms 2532 KB Output is correct
37 Correct 283 ms 2384 KB Output is correct
38 Correct 283 ms 2380 KB Output is correct
39 Correct 281 ms 2360 KB Output is correct
40 Correct 278 ms 2368 KB Output is correct
41 Correct 280 ms 2356 KB Output is correct
42 Correct 282 ms 2352 KB Output is correct
43 Correct 313 ms 2252 KB Output is correct
44 Correct 282 ms 2348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 256 ms 804 KB Output is correct
2 Correct 314 ms 976 KB Output is correct
3 Correct 285 ms 844 KB Output is correct
4 Correct 266 ms 752 KB Output is correct
5 Correct 276 ms 852 KB Output is correct
6 Correct 264 ms 788 KB Output is correct
7 Correct 282 ms 840 KB Output is correct
8 Correct 275 ms 856 KB Output is correct
9 Correct 276 ms 872 KB Output is correct
10 Correct 280 ms 848 KB Output is correct
11 Correct 276 ms 856 KB Output is correct
12 Correct 302 ms 796 KB Output is correct
13 Correct 279 ms 828 KB Output is correct
14 Correct 282 ms 852 KB Output is correct
15 Correct 275 ms 876 KB Output is correct
16 Correct 281 ms 768 KB Output is correct
17 Correct 277 ms 772 KB Output is correct
18 Correct 292 ms 900 KB Output is correct
19 Correct 3475 ms 3508 KB Output is correct
20 Execution timed out 7076 ms 3508 KB Time limit exceeded
21 Halted 0 ms 0 KB -