Submission #813278

# Submission time Handle Problem Language Result Execution time Memory
813278 2023-08-07T14:58:28 Z Cookie Crossing (JOI21_crossing) C++14
26 / 100
7000 ms 9788 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("VNOICUP.INP");
ofstream fout("VNOICUP.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
using u128 = __uint128_t;
//const int x[4] = {1, -1, 0, 0};
//const int y[4] = {0, 0, 1, -1};
ll mod = 1e9 + 9;
const int mxn = 2e5 + 5, mxq = 2e5 + 5, sq = 400, mxv = 2e5 + 5;
//const int base = (1 << 18);
const int inf = 1e9, base = 74, neg = -69420;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rr(ll l, ll r){
    return(uniform_int_distribution<ll>(l, r)(rng));
}
 
map<ll, int>mp;
int to[mxn + 1];
ll pw[mxn + 1], n, q;
string s[3], t;
string conv(string a, string b){
    string res = "";
    for(int i = 0; i < sz(a); i++){
        if(a[i] == b[i])res += a[i];
        else if(a[i] == 'J'){
            if(b[i] == 'O')res += 'I';
            else res += 'O';
        }else if(a[i] == 'O'){
            if(b[i] == 'J')res += 'I';
            else res += 'J';
        }else{
            if(b[i] == 'O')res += 'J';
            else res += 'O';
        }
    }
    return(res);
}
ll gethash(string s){
    ll ans = 0;
    for(int i = 0; i < sz(s); i++){
        ans += pw[i] * to[s[i]];
        ans %= mod;
    }
    return(ans);
}
 
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    mod = rr(1e9, 1e13);
    pw[0] = 1;
    for(int i = 1; i <= n; i++){
        pw[i] = (pw[i - 1] * base) % mod;
    }
    to['J'] =rr(1, 1000); to['O'] = rr(1,1000); to['I'] = rr(1, 1000);
    cin >> s[0] >> s[1] >> s[2];
    vt<string>v;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                v.pb(conv(conv(s[i], s[j]), s[k]));
            }
        }
    }
    
    
    cin >> q;
    cin >> t;
    bool ok = 0;
        forr(i, 0, sz(v)){
            if(t == v[i]){
                ok = 1; break;
            }
        }
        if(ok)cout << "Yes";
        else cout << "No";
        cout << "\n";
    while(q--){
        int l, r; char c; cin >> l >> r >> c; l--; r--;
        for(int i = l; i <= r; i++)t[i] = c;
        bool ok = 0;
        forr(i, 0, sz(v)){
            if(t == v[i]){
                ok = 1; break;
            }
        }
        if(ok)cout << "Yes";
        else cout << "No";
        cout << "\n";
    }
    
}

Compilation message

Main.cpp: In function 'long long int gethash(std::string)':
Main.cpp:55:31: warning: array subscript has type 'char' [-Wchar-subscripts]
   55 |         ans += pw[i] * to[s[i]];
      |                               ^
# Verdict Execution time Memory Grader output
1 Correct 47 ms 844 KB Output is correct
2 Correct 57 ms 824 KB Output is correct
3 Correct 57 ms 836 KB Output is correct
4 Correct 47 ms 824 KB Output is correct
5 Correct 54 ms 908 KB Output is correct
6 Correct 55 ms 864 KB Output is correct
7 Correct 47 ms 924 KB Output is correct
8 Correct 50 ms 896 KB Output is correct
9 Correct 49 ms 844 KB Output is correct
10 Correct 49 ms 892 KB Output is correct
11 Correct 50 ms 872 KB Output is correct
12 Correct 49 ms 848 KB Output is correct
13 Correct 49 ms 844 KB Output is correct
14 Correct 51 ms 884 KB Output is correct
15 Correct 55 ms 872 KB Output is correct
16 Correct 49 ms 852 KB Output is correct
17 Correct 49 ms 844 KB Output is correct
18 Correct 57 ms 916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 844 KB Output is correct
2 Correct 57 ms 824 KB Output is correct
3 Correct 57 ms 836 KB Output is correct
4 Correct 47 ms 824 KB Output is correct
5 Correct 54 ms 908 KB Output is correct
6 Correct 55 ms 864 KB Output is correct
7 Correct 47 ms 924 KB Output is correct
8 Correct 50 ms 896 KB Output is correct
9 Correct 49 ms 844 KB Output is correct
10 Correct 49 ms 892 KB Output is correct
11 Correct 50 ms 872 KB Output is correct
12 Correct 49 ms 848 KB Output is correct
13 Correct 49 ms 844 KB Output is correct
14 Correct 51 ms 884 KB Output is correct
15 Correct 55 ms 872 KB Output is correct
16 Correct 49 ms 852 KB Output is correct
17 Correct 49 ms 844 KB Output is correct
18 Correct 57 ms 916 KB Output is correct
19 Correct 3240 ms 9788 KB Output is correct
20 Execution timed out 7026 ms 9444 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 844 KB Output is correct
2 Correct 57 ms 824 KB Output is correct
3 Correct 57 ms 836 KB Output is correct
4 Correct 47 ms 824 KB Output is correct
5 Correct 54 ms 908 KB Output is correct
6 Correct 55 ms 864 KB Output is correct
7 Correct 47 ms 924 KB Output is correct
8 Correct 50 ms 896 KB Output is correct
9 Correct 49 ms 844 KB Output is correct
10 Correct 49 ms 892 KB Output is correct
11 Correct 50 ms 872 KB Output is correct
12 Correct 49 ms 848 KB Output is correct
13 Correct 49 ms 844 KB Output is correct
14 Correct 51 ms 884 KB Output is correct
15 Correct 55 ms 872 KB Output is correct
16 Correct 49 ms 852 KB Output is correct
17 Correct 49 ms 844 KB Output is correct
18 Correct 57 ms 916 KB Output is correct
19 Correct 47 ms 844 KB Output is correct
20 Correct 57 ms 872 KB Output is correct
21 Correct 56 ms 884 KB Output is correct
22 Correct 47 ms 2152 KB Output is correct
23 Correct 50 ms 2408 KB Output is correct
24 Correct 54 ms 2332 KB Output is correct
25 Correct 50 ms 2444 KB Output is correct
26 Correct 46 ms 2340 KB Output is correct
27 Correct 61 ms 2480 KB Output is correct
28 Correct 45 ms 2252 KB Output is correct
29 Correct 52 ms 2428 KB Output is correct
30 Correct 46 ms 2208 KB Output is correct
31 Correct 49 ms 2388 KB Output is correct
32 Correct 49 ms 2444 KB Output is correct
33 Correct 59 ms 2364 KB Output is correct
34 Correct 53 ms 2324 KB Output is correct
35 Correct 49 ms 2480 KB Output is correct
36 Correct 49 ms 2392 KB Output is correct
37 Correct 50 ms 2384 KB Output is correct
38 Correct 49 ms 2444 KB Output is correct
39 Correct 49 ms 2356 KB Output is correct
40 Correct 49 ms 2416 KB Output is correct
41 Correct 49 ms 2376 KB Output is correct
42 Correct 49 ms 2388 KB Output is correct
43 Correct 48 ms 2316 KB Output is correct
44 Correct 50 ms 2376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 844 KB Output is correct
2 Correct 57 ms 824 KB Output is correct
3 Correct 57 ms 836 KB Output is correct
4 Correct 47 ms 824 KB Output is correct
5 Correct 54 ms 908 KB Output is correct
6 Correct 55 ms 864 KB Output is correct
7 Correct 47 ms 924 KB Output is correct
8 Correct 50 ms 896 KB Output is correct
9 Correct 49 ms 844 KB Output is correct
10 Correct 49 ms 892 KB Output is correct
11 Correct 50 ms 872 KB Output is correct
12 Correct 49 ms 848 KB Output is correct
13 Correct 49 ms 844 KB Output is correct
14 Correct 51 ms 884 KB Output is correct
15 Correct 55 ms 872 KB Output is correct
16 Correct 49 ms 852 KB Output is correct
17 Correct 49 ms 844 KB Output is correct
18 Correct 57 ms 916 KB Output is correct
19 Correct 3240 ms 9788 KB Output is correct
20 Execution timed out 7026 ms 9444 KB Time limit exceeded
21 Halted 0 ms 0 KB -