Submission #429009

# Submission time Handle Problem Language Result Execution time Memory
429009 2021-06-15T16:34:14 Z muhammad_hokimiyon Crossing (JOI21_crossing) C++14
26 / 100
7000 ms 8892 KB
#include <bits/stdc++.h>

#define fi first
#define se second
#define ll long long
#define dl double

using namespace std;

const int N = 3e5 + 7;
const long long mod = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;
int a[N];

struct seg{
        int t[4 * N];
        int lz[4 * N];

        void build(int x, int l, int r)
        {
                if(l == r){
                        t[x] = a[l];
                        return;
                }
                int m = (l + r) / 2;
                build(x + x, l, m);
                build(x + x + 1, m + 1, r);
        }
};

vector<int> get(string s)
{
        vector<int> res;
        for(int i = 0; i < n; i++){
                if(s[i] == 'I')res.push_back(0);
                else if(s[i] == 'J')res.push_back(1);
                else res.push_back(2);
        }
        return res;
}

vector<vector<int>> col;

bool foo(vector<int> &x)
{
        for(auto y : col){
                bool f = true;
                for(int i = 0; i < n; i++){
                        f &= (y[i] == x[i]);
                }
                if(f)return true;
        }
        return false;
}

void solve()
{
        cin >> n;
        vector<int> a(n),b(n),c(n);
        set<vector<int>> s;
        string st;
        cin >> st;
        a = get(st);
        cin >> st;
        b = get(st);
        cin >> st;
        c = get(st);
        s.insert(a);
        s.insert(b);
        s.insert(c);
        while(true){
                bool f = false;
                vector<int> id;
                for(auto x : s){
                        for(auto y : s){
                               if(f)break;
                               vector<int> v;
                               for(int i = 0; i < n; i++){
                                        if(x[i] == y[i]){
                                                v.push_back(x[i]);
                                        }else v.push_back(3 - x[i] - y[i]);
                               }
                               if(s.find(v) == s.end()){
                                        id = v;
                                        f = true;
                               }
                        }
                }
                if(!f)break;
                s.insert(id);
        }
        assert((int)s.size() <= 10);
        for(auto x : s){
                col.push_back(x);
        }
        int q;
        cin >> q;
        cin >> st;
        auto x = get(st);
        if(foo(x))cout << "Yes\n";
        else cout << "No\n";
        while(q--){
                int l,r;
                char g;
                cin >> l >> r >> g;
                for(int i = l - 1; i < r; i++){
                        if(g == 'I')x[i] = 0;
                        else if(g == 'J')x[i] = 1;
                        else x[i] = 2;
                }
                if(foo(x))cout << "Yes\n";
                else cout << "No\n";
        }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 72 ms 1988 KB Output is correct
2 Correct 81 ms 2348 KB Output is correct
3 Correct 100 ms 2200 KB Output is correct
4 Correct 85 ms 2244 KB Output is correct
5 Correct 76 ms 2108 KB Output is correct
6 Correct 76 ms 2252 KB Output is correct
7 Correct 78 ms 2240 KB Output is correct
8 Correct 81 ms 2172 KB Output is correct
9 Correct 83 ms 2376 KB Output is correct
10 Correct 86 ms 2244 KB Output is correct
11 Correct 82 ms 2160 KB Output is correct
12 Correct 83 ms 2064 KB Output is correct
13 Correct 88 ms 2188 KB Output is correct
14 Correct 82 ms 2332 KB Output is correct
15 Correct 85 ms 2372 KB Output is correct
16 Correct 82 ms 2244 KB Output is correct
17 Correct 83 ms 2264 KB Output is correct
18 Correct 103 ms 2180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 1988 KB Output is correct
2 Correct 81 ms 2348 KB Output is correct
3 Correct 100 ms 2200 KB Output is correct
4 Correct 85 ms 2244 KB Output is correct
5 Correct 76 ms 2108 KB Output is correct
6 Correct 76 ms 2252 KB Output is correct
7 Correct 78 ms 2240 KB Output is correct
8 Correct 81 ms 2172 KB Output is correct
9 Correct 83 ms 2376 KB Output is correct
10 Correct 86 ms 2244 KB Output is correct
11 Correct 82 ms 2160 KB Output is correct
12 Correct 83 ms 2064 KB Output is correct
13 Correct 88 ms 2188 KB Output is correct
14 Correct 82 ms 2332 KB Output is correct
15 Correct 85 ms 2372 KB Output is correct
16 Correct 82 ms 2244 KB Output is correct
17 Correct 83 ms 2264 KB Output is correct
18 Correct 103 ms 2180 KB Output is correct
19 Execution timed out 7033 ms 8892 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 1988 KB Output is correct
2 Correct 81 ms 2348 KB Output is correct
3 Correct 100 ms 2200 KB Output is correct
4 Correct 85 ms 2244 KB Output is correct
5 Correct 76 ms 2108 KB Output is correct
6 Correct 76 ms 2252 KB Output is correct
7 Correct 78 ms 2240 KB Output is correct
8 Correct 81 ms 2172 KB Output is correct
9 Correct 83 ms 2376 KB Output is correct
10 Correct 86 ms 2244 KB Output is correct
11 Correct 82 ms 2160 KB Output is correct
12 Correct 83 ms 2064 KB Output is correct
13 Correct 88 ms 2188 KB Output is correct
14 Correct 82 ms 2332 KB Output is correct
15 Correct 85 ms 2372 KB Output is correct
16 Correct 82 ms 2244 KB Output is correct
17 Correct 83 ms 2264 KB Output is correct
18 Correct 103 ms 2180 KB Output is correct
19 Correct 317 ms 2188 KB Output is correct
20 Correct 349 ms 2228 KB Output is correct
21 Correct 145 ms 2244 KB Output is correct
22 Correct 110 ms 1732 KB Output is correct
23 Correct 143 ms 2372 KB Output is correct
24 Correct 135 ms 2248 KB Output is correct
25 Correct 146 ms 2268 KB Output is correct
26 Correct 123 ms 2284 KB Output is correct
27 Correct 147 ms 2492 KB Output is correct
28 Correct 130 ms 2204 KB Output is correct
29 Correct 148 ms 2248 KB Output is correct
30 Correct 110 ms 2124 KB Output is correct
31 Correct 352 ms 2244 KB Output is correct
32 Correct 323 ms 2168 KB Output is correct
33 Correct 329 ms 2104 KB Output is correct
34 Correct 243 ms 1912 KB Output is correct
35 Correct 328 ms 1348 KB Output is correct
36 Correct 331 ms 1732 KB Output is correct
37 Correct 328 ms 2188 KB Output is correct
38 Correct 333 ms 2300 KB Output is correct
39 Correct 328 ms 2244 KB Output is correct
40 Correct 336 ms 2364 KB Output is correct
41 Correct 329 ms 2264 KB Output is correct
42 Correct 332 ms 2376 KB Output is correct
43 Correct 283 ms 2128 KB Output is correct
44 Correct 326 ms 2088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 1988 KB Output is correct
2 Correct 81 ms 2348 KB Output is correct
3 Correct 100 ms 2200 KB Output is correct
4 Correct 85 ms 2244 KB Output is correct
5 Correct 76 ms 2108 KB Output is correct
6 Correct 76 ms 2252 KB Output is correct
7 Correct 78 ms 2240 KB Output is correct
8 Correct 81 ms 2172 KB Output is correct
9 Correct 83 ms 2376 KB Output is correct
10 Correct 86 ms 2244 KB Output is correct
11 Correct 82 ms 2160 KB Output is correct
12 Correct 83 ms 2064 KB Output is correct
13 Correct 88 ms 2188 KB Output is correct
14 Correct 82 ms 2332 KB Output is correct
15 Correct 85 ms 2372 KB Output is correct
16 Correct 82 ms 2244 KB Output is correct
17 Correct 83 ms 2264 KB Output is correct
18 Correct 103 ms 2180 KB Output is correct
19 Execution timed out 7033 ms 8892 KB Time limit exceeded
20 Halted 0 ms 0 KB -