Submission #620014

# Submission time Handle Problem Language Result Execution time Memory
620014 2022-08-02T18:47:31 Z APROHACK Crossing (JOI21_crossing) C++14
0 / 100
299 ms 2188 KB
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
ll n, q;
string a, b, c, x;
vector<string>strings;
set<string>st;
void input(){
    cin>>n;
    cin>>a>>b>>c;
    strings.pb(a);
    strings.pb(b);
    strings.pb(c);
    st.insert(a);
    st.insert(b);
    st.insert(c);
}
bool join(int a, int b){
    string nueva="";
    cout << a << " " << b << endl;
    for(int i = 0 ; i < n ; i++){
        if(strings[a][i]==strings[b][i]){
            nueva+=strings[a][i];
        }else {
            if(strings[a][i]=='J' && strings[b][i]=='O' || strings[b][i]=='J' && strings[a][i]=='O')nueva+="I";
            else if(strings[a][i]=='I' && strings[b][i]=='O' || strings[b][i]=='I' && strings[a][i]=='O')nueva+="J";
            else if(strings[a][i]=='I' && strings[b][i]=='J' || strings[b][i]=='I' && strings[a][i]=='J')nueva+="O";
        }
    }
    if(st.find(nueva)==st.end()){
        //cout << nueva << endl;
        st.insert(nueva);
        strings.pb(nueva);
    }else{
        return false;
    }
    return true;
}
void calculateString(){
    bool ans = true;
    while(ans){
        ans = false;
        int gen = strings.size();
        for(int i = 0 ; i < gen-1; i++){
            for(int j = i+1 ; j < gen ; j++){
                if(join(i, j))ans = true;
            }
        }
    }
}
void querys(){
    cin>>q;
    cin>>x;
    if(st.find(x)!=st.end())cout<<"Yes\n";
    else cout << "No\n";
    int l, r;
    char c;
    for(int i = 0 ;i  < q ; i++){
        cin>>l>>r>>c;
        for(int i = l-1 ; i <= r-1 ; i++){
            x[i]=c;
        }
        //cout << "ask "<<x<<endl;
        if(st.find(x)!=st.end())cout<<"Yes\n";
        else cout << "No\n";
    }
}
int main(){
    input();
    calculateString();
    querys();
}

Compilation message

Main.cpp: In function 'bool join(int, int)':
Main.cpp:28:35: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   28 |             if(strings[a][i]=='J' && strings[b][i]=='O' || strings[b][i]=='J' && strings[a][i]=='O')nueva+="I";
Main.cpp:29:40: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   29 |             else if(strings[a][i]=='I' && strings[b][i]=='O' || strings[b][i]=='I' && strings[a][i]=='O')nueva+="J";
Main.cpp:30:40: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   30 |             else if(strings[a][i]=='I' && strings[b][i]=='J' || strings[b][i]=='I' && strings[a][i]=='J')nueva+="O";
# Verdict Execution time Memory Grader output
1 Incorrect 299 ms 2188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 299 ms 2188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 299 ms 2188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 299 ms 2188 KB Output isn't correct
2 Halted 0 ms 0 KB -