Submission #876161

# Submission time Handle Problem Language Result Execution time Memory
876161 2023-11-21T10:33:50 Z green_gold_dog Crossing (JOI21_crossing) C++17
26 / 100
7000 ms 6060 KB
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,popcnt,mmx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;
typedef complex<double> cd;

constexpr ll INF64 = 9'000'000'000'000'000'000, INF32 = 2'000'000'000, MOD = 1'000'000'007;
constexpr db PI = acos(-1);
constexpr bool IS_FILE = false, IS_TEST_CASES = false;

random_device rd;
mt19937 rnd32(rd());
mt19937_64 rnd64(rd());

template<typename T>
bool assign_max(T& a, T b) {
        if (b > a) {
                a = b;
                return true;
        }
        return false;
}

template<typename T>
bool assign_min(T& a, T b) {
        if (b < a) {
                a = b;
                return true;
        }
        return false;
}

template<typename T>
T square(T a) {
        return a * a;
}

template<>
struct std::hash<pair<ll, ll>> {
        ll operator() (pair<ll, ll> p) const {
                return ((__int128)p.first * MOD + p.second) % INF64;
        }
};

map<pair<char, char>, char> m;

set<string> can;

string make(string& s1, string& s2) {
        string ans(s1.size(), '.');
        for (ll i = 0; i < s1.size(); i++) {
                ans[i] = m[make_pair(s1[i], s2[i])];
        }
        return ans;
}

void rec(string& s, string& s1, string& s2, string& s3) {
        can.insert(s);
        s = make(s, s1);
        if (can.find(s) == can.end()) {
                rec(s, s1, s2, s3);
        }
        s = make(s, s1);
        s = make(s, s2);
        if (can.find(s) == can.end()) {
                rec(s, s1, s2, s3);
        }
        s = make(s, s2);
        s = make(s, s3);
        if (can.find(s) == can.end()) {
                rec(s, s1, s2, s3);
        }
        s = make(s, s3);
}

void solve() {
        m[make_pair('O', 'O')] = 'O';
        m[make_pair('O', 'I')] = 'J';
        m[make_pair('O', 'J')] = 'I';
        m[make_pair('I', 'O')] = 'J';
        m[make_pair('I', 'I')] = 'I';
        m[make_pair('I', 'J')] = 'O';
        m[make_pair('J', 'O')] = 'I';
        m[make_pair('J', 'I')] = 'O';
        m[make_pair('J', 'J')] = 'J';
        ll n;
        cin >> n;
        string s1, s2, s3;
        cin >> s1 >> s2 >> s3;
        string s = s1;
        rec(s, s1, s2, s3);
        ll q;
        cin >> q;
        cin >> s;
        cout << (can.find(s) == can.end() ? "No" : "Yes") << '\n';
        for (ll i = 0; i < q; i++) {
                ll l, r;
                char c;
                cin >> l >> r >> c;
                l--;
                for (ll j = l; j < r; j++) {
                        s[j] = c;
                }
                cout << (can.find(s) == can.end() ? "No" : "Yes") << '\n';
        }
}

int main() {
        if (IS_FILE) {
                freopen("", "r", stdin);
                freopen("", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        ll t = 1;
        if (IS_TEST_CASES) {
                cin >> t;
        }
        for (ll i = 0; i < t; i++) {
                solve();
        }
}

Compilation message

Main.cpp: In function 'std::string make(std::string&, std::string&)':
Main.cpp:56:26: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         for (ll i = 0; i < s1.size(); i++) {
      |                        ~~^~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:115:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  115 |                 freopen("", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~
Main.cpp:116:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  116 |                 freopen("", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2404 KB Output is correct
2 Correct 36 ms 2368 KB Output is correct
3 Correct 45 ms 2280 KB Output is correct
4 Correct 35 ms 2388 KB Output is correct
5 Correct 34 ms 2392 KB Output is correct
6 Correct 36 ms 2260 KB Output is correct
7 Correct 34 ms 2364 KB Output is correct
8 Correct 36 ms 2388 KB Output is correct
9 Correct 35 ms 2388 KB Output is correct
10 Correct 35 ms 2388 KB Output is correct
11 Correct 37 ms 2384 KB Output is correct
12 Correct 37 ms 2384 KB Output is correct
13 Correct 37 ms 2364 KB Output is correct
14 Correct 36 ms 2384 KB Output is correct
15 Correct 36 ms 2392 KB Output is correct
16 Correct 36 ms 2388 KB Output is correct
17 Correct 35 ms 2480 KB Output is correct
18 Correct 47 ms 2456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2404 KB Output is correct
2 Correct 36 ms 2368 KB Output is correct
3 Correct 45 ms 2280 KB Output is correct
4 Correct 35 ms 2388 KB Output is correct
5 Correct 34 ms 2392 KB Output is correct
6 Correct 36 ms 2260 KB Output is correct
7 Correct 34 ms 2364 KB Output is correct
8 Correct 36 ms 2388 KB Output is correct
9 Correct 35 ms 2388 KB Output is correct
10 Correct 35 ms 2388 KB Output is correct
11 Correct 37 ms 2384 KB Output is correct
12 Correct 37 ms 2384 KB Output is correct
13 Correct 37 ms 2364 KB Output is correct
14 Correct 36 ms 2384 KB Output is correct
15 Correct 36 ms 2392 KB Output is correct
16 Correct 36 ms 2388 KB Output is correct
17 Correct 35 ms 2480 KB Output is correct
18 Correct 47 ms 2456 KB Output is correct
19 Correct 3221 ms 6060 KB Output is correct
20 Execution timed out 7057 ms 3676 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2404 KB Output is correct
2 Correct 36 ms 2368 KB Output is correct
3 Correct 45 ms 2280 KB Output is correct
4 Correct 35 ms 2388 KB Output is correct
5 Correct 34 ms 2392 KB Output is correct
6 Correct 36 ms 2260 KB Output is correct
7 Correct 34 ms 2364 KB Output is correct
8 Correct 36 ms 2388 KB Output is correct
9 Correct 35 ms 2388 KB Output is correct
10 Correct 35 ms 2388 KB Output is correct
11 Correct 37 ms 2384 KB Output is correct
12 Correct 37 ms 2384 KB Output is correct
13 Correct 37 ms 2364 KB Output is correct
14 Correct 36 ms 2384 KB Output is correct
15 Correct 36 ms 2392 KB Output is correct
16 Correct 36 ms 2388 KB Output is correct
17 Correct 35 ms 2480 KB Output is correct
18 Correct 47 ms 2456 KB Output is correct
19 Correct 37 ms 2396 KB Output is correct
20 Correct 46 ms 2268 KB Output is correct
21 Correct 37 ms 2384 KB Output is correct
22 Correct 33 ms 2132 KB Output is correct
23 Correct 40 ms 2384 KB Output is correct
24 Correct 35 ms 2264 KB Output is correct
25 Correct 38 ms 2388 KB Output is correct
26 Correct 35 ms 2392 KB Output is correct
27 Correct 38 ms 2388 KB Output is correct
28 Correct 40 ms 2388 KB Output is correct
29 Correct 42 ms 2384 KB Output is correct
30 Correct 34 ms 2392 KB Output is correct
31 Correct 39 ms 2368 KB Output is correct
32 Correct 39 ms 2388 KB Output is correct
33 Correct 39 ms 2388 KB Output is correct
34 Correct 36 ms 2388 KB Output is correct
35 Correct 39 ms 2384 KB Output is correct
36 Correct 38 ms 2388 KB Output is correct
37 Correct 44 ms 2384 KB Output is correct
38 Correct 39 ms 2580 KB Output is correct
39 Correct 40 ms 2384 KB Output is correct
40 Correct 41 ms 2420 KB Output is correct
41 Correct 39 ms 2384 KB Output is correct
42 Correct 38 ms 2504 KB Output is correct
43 Correct 46 ms 2388 KB Output is correct
44 Correct 41 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2404 KB Output is correct
2 Correct 36 ms 2368 KB Output is correct
3 Correct 45 ms 2280 KB Output is correct
4 Correct 35 ms 2388 KB Output is correct
5 Correct 34 ms 2392 KB Output is correct
6 Correct 36 ms 2260 KB Output is correct
7 Correct 34 ms 2364 KB Output is correct
8 Correct 36 ms 2388 KB Output is correct
9 Correct 35 ms 2388 KB Output is correct
10 Correct 35 ms 2388 KB Output is correct
11 Correct 37 ms 2384 KB Output is correct
12 Correct 37 ms 2384 KB Output is correct
13 Correct 37 ms 2364 KB Output is correct
14 Correct 36 ms 2384 KB Output is correct
15 Correct 36 ms 2392 KB Output is correct
16 Correct 36 ms 2388 KB Output is correct
17 Correct 35 ms 2480 KB Output is correct
18 Correct 47 ms 2456 KB Output is correct
19 Correct 3221 ms 6060 KB Output is correct
20 Execution timed out 7057 ms 3676 KB Time limit exceeded
21 Halted 0 ms 0 KB -