Submission #771064

# Submission time Handle Problem Language Result Execution time Memory
771064 2023-07-02T12:12:10 Z davitmarg Crossing (JOI21_crossing) C++17
0 / 100
135 ms 43164 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<string, bool> used;

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]);

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

    cin >> q;

    string t;
    cin >> t;
    if (used[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[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++)
      |                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 43164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 43164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 43164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 43164 KB Output isn't correct
2 Halted 0 ms 0 KB -