Submission #1059364

# Submission time Handle Problem Language Result Execution time Memory
1059364 2024-08-14T21:51:35 Z SN0WM4N Crossing (JOI21_crossing) C++14
26 / 100
7000 ms 5320 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sort undefined_function // To use stable_sort instead sort 
#define bpc __builtin_popcount
#define ull unsigned long long
#define ld double
#define ll long long
#define mp make_pair
#define F first
#define S second
 
#pragma GCC optimize("O3")
 
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<long long, null_type, less_equal<long long>,
    rb_tree_tag, tree_order_statistics_node_update> Tree;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll INF = 9223372036854775807LL;
const ll inf = 2147483647;
const ll MOD = 998244353; //[998244353, 1e9 + 7, 1e9 + 13]
const ld PI = acos(-1);
const ll NROOT = 300;
 
ll binpow(ll a, ll b, ll _MOD = -1) {
        if (_MOD == -1)
                _MOD = MOD;
        ll res = 1;
        for (; b; b /= 2, a *= a, a %= _MOD)
                if (b & 1) res *= a, res %= _MOD;
        return res;
}
 
void set_IO(string s) {
#ifndef LOCAL
        string in  = s +  ".in";
        string out = s + ".out";
        freopen(in.c_str(),  "r",  stdin);
        freopen(out.c_str(), "w", stdout);
#endif
}
 
bool dataOverflow(ll a, ll b) {return (log10(a) + log10(b) >= 18);}
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a * b / gcd(a, b);}
ll ceil(ll a, ll b) {return (a + b - 1) / b;}
 
string match(string a, string b) {
        string ans = a;
        for (int i = 0; i < (int)a.size(); i ++) {
                if (a[i] == b[i]) {
                        ans[i] = a[i];
                } else {
                        set<char> s = {'J', 'O', 'I'};
                        s.erase(s.find(a[i]));
                        s.erase(s.find(b[i]));
                        ans[i] = *s.begin();
                }
        }
        return ans;
}

int32_t main() {
        ios_base::sync_with_stdio(0);
        cin.tie(0);

        int n;
        cin >> n;

        set<string> c;
        for (int i = 1; i <= 3; i ++) {
                string s;
                cin >> s;

                c.insert(s);
        }

        bool ok = 1;
        while (ok && c.size() <= 1e4) {
                set<string> aux;
                ok = 0;
                for (auto &a : c) {
                        for (auto &b : c) {
                                string d = match(a, b);
                                if (!c.count(d))
                                        ok = 1;
                                aux.insert(d);
                        }
                }

                for (auto &x : aux)
                        c.insert(x);
        }       

        int q;
        cin >> q;
        string t;
        cin >> t;

        cout << (c.count(t) ? "Yes\n" : "No\n");

        while (q --) {
                int l, r; char m;
                cin >> l >> r >> m;
                l --; r --;

                for (int i = l; i <= r; i ++)
                        t[i] = m;

                cout << (c.count(t) ? "Yes\n" : "No\n");
        }

        return 0;
}

Compilation message

Main.cpp: In function 'void set_IO(std::string)':
Main.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen(in.c_str(),  "r",  stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen(out.c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2396 KB Output is correct
2 Correct 21 ms 2464 KB Output is correct
3 Correct 31 ms 2396 KB Output is correct
4 Correct 20 ms 2396 KB Output is correct
5 Correct 21 ms 2396 KB Output is correct
6 Correct 20 ms 2392 KB Output is correct
7 Correct 20 ms 2388 KB Output is correct
8 Correct 22 ms 2392 KB Output is correct
9 Correct 21 ms 2392 KB Output is correct
10 Correct 22 ms 2388 KB Output is correct
11 Correct 21 ms 2392 KB Output is correct
12 Correct 22 ms 2384 KB Output is correct
13 Correct 22 ms 2564 KB Output is correct
14 Correct 24 ms 2396 KB Output is correct
15 Correct 21 ms 2392 KB Output is correct
16 Correct 22 ms 2584 KB Output is correct
17 Correct 24 ms 2644 KB Output is correct
18 Correct 38 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2396 KB Output is correct
2 Correct 21 ms 2464 KB Output is correct
3 Correct 31 ms 2396 KB Output is correct
4 Correct 20 ms 2396 KB Output is correct
5 Correct 21 ms 2396 KB Output is correct
6 Correct 20 ms 2392 KB Output is correct
7 Correct 20 ms 2388 KB Output is correct
8 Correct 22 ms 2392 KB Output is correct
9 Correct 21 ms 2392 KB Output is correct
10 Correct 22 ms 2388 KB Output is correct
11 Correct 21 ms 2392 KB Output is correct
12 Correct 22 ms 2384 KB Output is correct
13 Correct 22 ms 2564 KB Output is correct
14 Correct 24 ms 2396 KB Output is correct
15 Correct 21 ms 2392 KB Output is correct
16 Correct 22 ms 2584 KB Output is correct
17 Correct 24 ms 2644 KB Output is correct
18 Correct 38 ms 2388 KB Output is correct
19 Correct 3649 ms 5320 KB Output is correct
20 Execution timed out 7038 ms 3012 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2396 KB Output is correct
2 Correct 21 ms 2464 KB Output is correct
3 Correct 31 ms 2396 KB Output is correct
4 Correct 20 ms 2396 KB Output is correct
5 Correct 21 ms 2396 KB Output is correct
6 Correct 20 ms 2392 KB Output is correct
7 Correct 20 ms 2388 KB Output is correct
8 Correct 22 ms 2392 KB Output is correct
9 Correct 21 ms 2392 KB Output is correct
10 Correct 22 ms 2388 KB Output is correct
11 Correct 21 ms 2392 KB Output is correct
12 Correct 22 ms 2384 KB Output is correct
13 Correct 22 ms 2564 KB Output is correct
14 Correct 24 ms 2396 KB Output is correct
15 Correct 21 ms 2392 KB Output is correct
16 Correct 22 ms 2584 KB Output is correct
17 Correct 24 ms 2644 KB Output is correct
18 Correct 38 ms 2388 KB Output is correct
19 Correct 25 ms 2388 KB Output is correct
20 Correct 35 ms 2340 KB Output is correct
21 Correct 23 ms 2396 KB Output is correct
22 Correct 20 ms 2392 KB Output is correct
23 Correct 24 ms 2396 KB Output is correct
24 Correct 22 ms 2388 KB Output is correct
25 Correct 23 ms 2384 KB Output is correct
26 Correct 23 ms 2384 KB Output is correct
27 Correct 23 ms 2396 KB Output is correct
28 Correct 21 ms 2404 KB Output is correct
29 Correct 23 ms 2396 KB Output is correct
30 Correct 20 ms 2396 KB Output is correct
31 Correct 28 ms 2388 KB Output is correct
32 Correct 27 ms 2384 KB Output is correct
33 Correct 25 ms 2372 KB Output is correct
34 Correct 23 ms 2388 KB Output is correct
35 Correct 24 ms 2384 KB Output is correct
36 Correct 24 ms 2396 KB Output is correct
37 Correct 25 ms 2384 KB Output is correct
38 Correct 24 ms 2388 KB Output is correct
39 Correct 25 ms 2384 KB Output is correct
40 Correct 26 ms 2384 KB Output is correct
41 Correct 25 ms 2484 KB Output is correct
42 Correct 23 ms 2396 KB Output is correct
43 Correct 23 ms 2396 KB Output is correct
44 Correct 25 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2396 KB Output is correct
2 Correct 21 ms 2464 KB Output is correct
3 Correct 31 ms 2396 KB Output is correct
4 Correct 20 ms 2396 KB Output is correct
5 Correct 21 ms 2396 KB Output is correct
6 Correct 20 ms 2392 KB Output is correct
7 Correct 20 ms 2388 KB Output is correct
8 Correct 22 ms 2392 KB Output is correct
9 Correct 21 ms 2392 KB Output is correct
10 Correct 22 ms 2388 KB Output is correct
11 Correct 21 ms 2392 KB Output is correct
12 Correct 22 ms 2384 KB Output is correct
13 Correct 22 ms 2564 KB Output is correct
14 Correct 24 ms 2396 KB Output is correct
15 Correct 21 ms 2392 KB Output is correct
16 Correct 22 ms 2584 KB Output is correct
17 Correct 24 ms 2644 KB Output is correct
18 Correct 38 ms 2388 KB Output is correct
19 Correct 3649 ms 5320 KB Output is correct
20 Execution timed out 7038 ms 3012 KB Time limit exceeded
21 Halted 0 ms 0 KB -