Submission #881394

#TimeUsernameProblemLanguageResultExecution timeMemory
881394DanetCrossing (JOI21_crossing)C++14
26 / 100
7063 ms5300 KiB
#include<bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3")

#define tof_io  ios_base::sync_with_stdio(false);cin.tie(0) , cout.tie(0);
#define double  long double
#define int     long long
#define pb      push_back
#define all(x)  x.begin(),x.end()
#define endl    '\n'

const int mod = 1e9+7; //998244353
const long long inf = 1e18;
const int N = 1e3 + 23;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
vector<string> str;
set<string> st;
vector<string>sz;
string t;
//all==sz;
//str == now;
//dict = st;
char cr(char a , char b)
{
    if(a == b) return a;
    if(a != 'J' and b!='J') return 'J';
    if(a != 'I' and b!='I') return 'I';
    if(a != 'O' and b!='O') return 'O';
    return 'I';
}
string cr2(string a , string b)
{
    string ans;
    for(int i = 0; i < a.size(); i++)
    {
        ans = ans + cr(a[i] , b[i]);
    }
    return ans;
}

int32_t main() 
{
    tof_io;
    int n;
    int q;
    cin >> n;
    string s1 , s2 , s3;
    cin >> s1 >> s2 >> s3;
    str.pb(s1);
    str.pb(s2);
    str.pb(s3);
    while (str.empty() == 0) 
    {
        string re = str.back();
        str.pop_back();
        if (st.find(re) == st.end())
        {
            st.insert(re);
            sz.pb(re);  
            for (string k : sz) 
            {
                str.pb(cr2(re, k));
            }
        }
    }
    cin >> q >> t;
    bool fl = 0;
    for (string x : sz) 
    {
        if (t == x) fl = 1;
    }
    if(fl == 1) cout << "Yes";
    else cout <<"No";
    cout << endl;
    while (q--) 
    {
        int l  , r ;
        char c;
        cin >> l >> r >> c;
        for (int j = l - 1; j <= r - 1; j++)  t[j] = c;
        ///
        bool fl = 0;
        for (string x : sz) 
        {
            if (t == x) fl = 1;
        }
        if(fl == 1) cout << "Yes";
        else cout <<"No";
        cout << endl;
        //
    }
}

Compilation message (stderr)

Main.cpp: In function 'std::string cr2(std::string, std::string)':
Main.cpp:36:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i = 0; i < a.size(); i++)
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...