Submission #771073

# Submission time Handle Problem Language Result Execution time Memory
771073 2023-07-02T12:23:51 Z davitmarg Crossing (JOI21_crossing) C++17
26 / 100
7000 ms 28620 KB
/*
DavitMarg
In a honky-tonk,
Down in Mexico
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <random>
#include <chrono>
#define mod 998244353ll
#define LL long long
#define LD long double
#define MP make_pair    
#define PB push_back
#define all(v) v.begin(), v.end()
#define fastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

const int N = 500005;


string crossing(string a, string b)
{
    string s = a;
    for (int i = 0; i < a.length(); i++)
    {
        if (a[i] == b[i])
            continue;
        s[i] = '0' + ((a[i] - '0') ^ (b[i] - '0'));
    }
    return s;
}

string norm(string s)
{
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'J')
            s[i] = '1';
        else if(s[i] == 'O')
			s[i] = '2';
		else
			s[i] = '3';
    }
    return s;
}

int n, q;
string s[N];
map<LL, bool> used;

LL prime = 271;
LL pr[N];

void hashInit()
{
    pr[0] = 1;
    for(int i = 1; i <= n; i++)
		pr[i] = (pr[i - 1] * prime) % mod;
}

LL getHash(string s)
{
	LL h = 0;
	for(int i = 0; i < s.length(); i++)
        h = (h + ((LL)(s[i] - '0') + 1ll) * pr[i]) % mod;
	return h;
}

void solve()
{
    cin >> n;
    cin >> s[1] >> s[2] >> s[3];
    s[1] = norm(s[1]);
    s[2] = norm(s[2]);
    s[3] = norm(s[3]);

    hashInit();

    for (int i = 1; i <= 3; i++)
        for (int j = 1; j <= 3; j++)
            for (int k = 1; k <= 3; k++)
                used[getHash(crossing(crossing(s[i], s[j]), s[k]))] = 1;

    cin >> q;

    string t;
    cin >> t;
    if (used[getHash(norm(t))])
		cout << "Yes\n";
	else
		cout << "No\n";

    for (int i = 1; i <= q; i++)
    {
        int l, r;
        char c;
        cin>>l>>r>>c;
        for(int j = l - 1; j <= r - 1; j++)
            t[j] = c;

        if (used[getHash(norm(t))])
            cout << "Yes\n";
		else
			cout << "No\n";
    }
}


int main()
{
    fastIO;
    int T = 1;
    //cin >> T;
    while (T--)
    {
        solve();
    }

    return 0;
}

/*


*/

Compilation message

Main.cpp: In function 'std::string crossing(std::string, std::string)':
Main.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int i = 0; i < a.length(); i++)
      |                     ~~^~~~~~~~~~~~
Main.cpp: In function 'std::string norm(std::string)':
Main.cpp:50:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for (int i = 0; i < s.length(); i++)
      |                     ~~^~~~~~~~~~~~
Main.cpp: In function 'long long int getHash(std::string)':
Main.cpp:79:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |  for(int i = 0; i < s.length(); i++)
      |                 ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 165 ms 26692 KB Output is correct
2 Correct 192 ms 27160 KB Output is correct
3 Correct 176 ms 20592 KB Output is correct
4 Correct 201 ms 27140 KB Output is correct
5 Correct 188 ms 27260 KB Output is correct
6 Correct 210 ms 26344 KB Output is correct
7 Correct 179 ms 26696 KB Output is correct
8 Correct 214 ms 27468 KB Output is correct
9 Correct 198 ms 27136 KB Output is correct
10 Correct 212 ms 28620 KB Output is correct
11 Correct 203 ms 27884 KB Output is correct
12 Correct 207 ms 28544 KB Output is correct
13 Correct 209 ms 27836 KB Output is correct
14 Correct 208 ms 28568 KB Output is correct
15 Correct 201 ms 27824 KB Output is correct
16 Correct 212 ms 28544 KB Output is correct
17 Correct 207 ms 27844 KB Output is correct
18 Correct 162 ms 18860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 165 ms 26692 KB Output is correct
2 Correct 192 ms 27160 KB Output is correct
3 Correct 176 ms 20592 KB Output is correct
4 Correct 201 ms 27140 KB Output is correct
5 Correct 188 ms 27260 KB Output is correct
6 Correct 210 ms 26344 KB Output is correct
7 Correct 179 ms 26696 KB Output is correct
8 Correct 214 ms 27468 KB Output is correct
9 Correct 198 ms 27136 KB Output is correct
10 Correct 212 ms 28620 KB Output is correct
11 Correct 203 ms 27884 KB Output is correct
12 Correct 207 ms 28544 KB Output is correct
13 Correct 209 ms 27836 KB Output is correct
14 Correct 208 ms 28568 KB Output is correct
15 Correct 201 ms 27824 KB Output is correct
16 Correct 212 ms 28544 KB Output is correct
17 Correct 207 ms 27844 KB Output is correct
18 Correct 162 ms 18860 KB Output is correct
19 Execution timed out 7030 ms 19972 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 165 ms 26692 KB Output is correct
2 Correct 192 ms 27160 KB Output is correct
3 Correct 176 ms 20592 KB Output is correct
4 Correct 201 ms 27140 KB Output is correct
5 Correct 188 ms 27260 KB Output is correct
6 Correct 210 ms 26344 KB Output is correct
7 Correct 179 ms 26696 KB Output is correct
8 Correct 214 ms 27468 KB Output is correct
9 Correct 198 ms 27136 KB Output is correct
10 Correct 212 ms 28620 KB Output is correct
11 Correct 203 ms 27884 KB Output is correct
12 Correct 207 ms 28544 KB Output is correct
13 Correct 209 ms 27836 KB Output is correct
14 Correct 208 ms 28568 KB Output is correct
15 Correct 201 ms 27824 KB Output is correct
16 Correct 212 ms 28544 KB Output is correct
17 Correct 207 ms 27844 KB Output is correct
18 Correct 162 ms 18860 KB Output is correct
19 Correct 190 ms 26244 KB Output is correct
20 Correct 171 ms 20228 KB Output is correct
21 Correct 209 ms 27492 KB Output is correct
22 Correct 169 ms 25496 KB Output is correct
23 Correct 204 ms 27612 KB Output is correct
24 Correct 190 ms 26492 KB Output is correct
25 Correct 218 ms 27400 KB Output is correct
26 Correct 165 ms 26156 KB Output is correct
27 Correct 207 ms 27444 KB Output is correct
28 Correct 181 ms 26492 KB Output is correct
29 Correct 197 ms 26872 KB Output is correct
30 Correct 156 ms 25868 KB Output is correct
31 Correct 225 ms 27772 KB Output is correct
32 Correct 205 ms 27636 KB Output is correct
33 Correct 206 ms 27064 KB Output is correct
34 Correct 172 ms 26160 KB Output is correct
35 Correct 220 ms 28080 KB Output is correct
36 Correct 218 ms 27284 KB Output is correct
37 Correct 213 ms 28144 KB Output is correct
38 Correct 208 ms 27420 KB Output is correct
39 Correct 215 ms 28048 KB Output is correct
40 Correct 218 ms 27260 KB Output is correct
41 Correct 206 ms 28164 KB Output is correct
42 Correct 208 ms 27292 KB Output is correct
43 Correct 177 ms 26700 KB Output is correct
44 Correct 204 ms 27048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 165 ms 26692 KB Output is correct
2 Correct 192 ms 27160 KB Output is correct
3 Correct 176 ms 20592 KB Output is correct
4 Correct 201 ms 27140 KB Output is correct
5 Correct 188 ms 27260 KB Output is correct
6 Correct 210 ms 26344 KB Output is correct
7 Correct 179 ms 26696 KB Output is correct
8 Correct 214 ms 27468 KB Output is correct
9 Correct 198 ms 27136 KB Output is correct
10 Correct 212 ms 28620 KB Output is correct
11 Correct 203 ms 27884 KB Output is correct
12 Correct 207 ms 28544 KB Output is correct
13 Correct 209 ms 27836 KB Output is correct
14 Correct 208 ms 28568 KB Output is correct
15 Correct 201 ms 27824 KB Output is correct
16 Correct 212 ms 28544 KB Output is correct
17 Correct 207 ms 27844 KB Output is correct
18 Correct 162 ms 18860 KB Output is correct
19 Execution timed out 7030 ms 19972 KB Time limit exceeded
20 Halted 0 ms 0 KB -