답안 #936385

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
936385 2024-03-01T18:26:26 Z ace5 Crossing (JOI21_crossing) C++17
26 / 100
7000 ms 37388 KB
#include <bits/stdc++.h>

using namespace std;

#define int int64_t

int getint(char c)
{
    return (c == 'J' ? 0 : (c == 'O' ? 1 : 2));
}

struct Streq
{
    Streq(vector<int> _et,vector<int> _cur){et = _et;cur = _cur;};
    Streq(){et = {};cur = {};};
    vector<int> et;
    vector<int> cur;

    bool isGood()
    {
        return et == cur;
    }

    void modify(int l,int r,int f)
    {
        for(int i = l;i <= r;++i)
        {
            cur[i] = f;
        }
    }
};

vector<vector<Streq>> ms(5,vector<Streq>(3));

bool can_get()
{
    bool no = 0;
    for(int i = 0;i < 5;++i)
    {
        bool y = 0;
        for(int j = 0;j < 3;++j)
        {
            if(ms[i][j].isGood())
                y = 1;
        }
        if(!y)
            no = 1;
    }
    return !no;
}
void print_ans()
{
    cout << (can_get() ? "Yes\n" : "No\n");
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string aa,bb,cc;
    cin >> aa >> bb >> cc;
    vector<int> a(n),b(n),c(n);
    for(int i = 0;i < n;++i)
    {
        a[i] = getint(aa[i]);
        b[i] = getint(bb[i]);
        c[i] = getint(cc[i]);
    }
    vector<vector<int>> ix(5);
    vector<vector<int>> ind;
    for(int i = 0;i < n;++i)
    {
        if(a[i] == b[i] && a[i] != c[i])
        {
            ix[0].push_back(i);
            ind.push_back({a[i],c[i],3 - a[i] - c[i]});
        }
        if(a[i] == c[i] && a[i] != b[i])
        {
            ix[1].push_back(i);
            ind.push_back({a[i],b[i],3 - a[i] - b[i]});
        }
        if(c[i] == b[i] && a[i] != c[i])
        {
            ix[2].push_back(i);
            ind.push_back({b[i],a[i],3 - a[i] - b[i]});
        }
        if(a[i] != b[i] && a[i] != c[i] && b[i] != c[i])
        {
            ix[3].push_back(i);
            ind.push_back({a[i],b[i],c[i]});
        }
        if(a[i] == b[i] && b[i] ==c[i])
        {
            ix[4].push_back(i);
            ind.push_back({a[i],a[i],a[i]});
        }
    }
    int q;
    cin >> q;
    string t0;
    cin >> t0;
    for(int i = 0;i < 5;++i)
    {
        for(int j = 0;j < 3;++j)
        {
            vector<int> tet,tcur;
            for(int k = 0;k < ix[i].size();++k)
            {
                tet.push_back(ind[ix[i][k]][j]);
                tcur.push_back(getint(t0[ix[i][k]]));
            }
            ms[i][j].et = tet;
            ms[i][j].cur = tcur;
        }
    }
    print_ans();
    while(q--)
    {
        int l,r;
        char cc;
        cin >> l >> r >> cc;
        l--;
        r--;
        int f = getint(cc);
        for(int i = 0;i < 5;++i)
        {
            int lg = lower_bound(ix[i].begin(),ix[i].end(),l)-ix[i].begin();
            int rg = upper_bound(ix[i].begin(),ix[i].end(),r)-ix[i].begin()-1;
            for(int j = 0;j < 3;++j)
                ms[i][j].modify(lg,rg,f);
        }
        print_ans();
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:111:29: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  111 |             for(int k = 0;k < ix[i].size();++k)
      |                           ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 2424 KB Output is correct
2 Correct 59 ms 2604 KB Output is correct
3 Correct 72 ms 2384 KB Output is correct
4 Correct 59 ms 2364 KB Output is correct
5 Correct 53 ms 2440 KB Output is correct
6 Correct 52 ms 2220 KB Output is correct
7 Correct 57 ms 2388 KB Output is correct
8 Correct 56 ms 2544 KB Output is correct
9 Correct 55 ms 2524 KB Output is correct
10 Correct 59 ms 2596 KB Output is correct
11 Correct 55 ms 2556 KB Output is correct
12 Correct 57 ms 2544 KB Output is correct
13 Correct 57 ms 2588 KB Output is correct
14 Correct 57 ms 2384 KB Output is correct
15 Correct 56 ms 2388 KB Output is correct
16 Correct 57 ms 2388 KB Output is correct
17 Correct 55 ms 2360 KB Output is correct
18 Correct 75 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 2424 KB Output is correct
2 Correct 59 ms 2604 KB Output is correct
3 Correct 72 ms 2384 KB Output is correct
4 Correct 59 ms 2364 KB Output is correct
5 Correct 53 ms 2440 KB Output is correct
6 Correct 52 ms 2220 KB Output is correct
7 Correct 57 ms 2388 KB Output is correct
8 Correct 56 ms 2544 KB Output is correct
9 Correct 55 ms 2524 KB Output is correct
10 Correct 59 ms 2596 KB Output is correct
11 Correct 55 ms 2556 KB Output is correct
12 Correct 57 ms 2544 KB Output is correct
13 Correct 57 ms 2588 KB Output is correct
14 Correct 57 ms 2384 KB Output is correct
15 Correct 56 ms 2388 KB Output is correct
16 Correct 57 ms 2388 KB Output is correct
17 Correct 55 ms 2360 KB Output is correct
18 Correct 75 ms 2284 KB Output is correct
19 Correct 5061 ms 37388 KB Output is correct
20 Execution timed out 7011 ms 36292 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 2424 KB Output is correct
2 Correct 59 ms 2604 KB Output is correct
3 Correct 72 ms 2384 KB Output is correct
4 Correct 59 ms 2364 KB Output is correct
5 Correct 53 ms 2440 KB Output is correct
6 Correct 52 ms 2220 KB Output is correct
7 Correct 57 ms 2388 KB Output is correct
8 Correct 56 ms 2544 KB Output is correct
9 Correct 55 ms 2524 KB Output is correct
10 Correct 59 ms 2596 KB Output is correct
11 Correct 55 ms 2556 KB Output is correct
12 Correct 57 ms 2544 KB Output is correct
13 Correct 57 ms 2588 KB Output is correct
14 Correct 57 ms 2384 KB Output is correct
15 Correct 56 ms 2388 KB Output is correct
16 Correct 57 ms 2388 KB Output is correct
17 Correct 55 ms 2360 KB Output is correct
18 Correct 75 ms 2284 KB Output is correct
19 Correct 80 ms 2420 KB Output is correct
20 Correct 85 ms 2672 KB Output is correct
21 Correct 69 ms 2588 KB Output is correct
22 Correct 60 ms 2260 KB Output is correct
23 Correct 65 ms 2500 KB Output is correct
24 Correct 70 ms 2640 KB Output is correct
25 Correct 67 ms 2396 KB Output is correct
26 Correct 58 ms 2388 KB Output is correct
27 Correct 66 ms 2464 KB Output is correct
28 Correct 58 ms 2224 KB Output is correct
29 Correct 63 ms 2512 KB Output is correct
30 Correct 59 ms 2412 KB Output is correct
31 Correct 79 ms 2384 KB Output is correct
32 Correct 85 ms 2496 KB Output is correct
33 Correct 81 ms 2464 KB Output is correct
34 Correct 77 ms 2336 KB Output is correct
35 Correct 76 ms 2480 KB Output is correct
36 Correct 75 ms 2472 KB Output is correct
37 Correct 75 ms 2492 KB Output is correct
38 Correct 75 ms 2388 KB Output is correct
39 Correct 77 ms 2388 KB Output is correct
40 Correct 76 ms 2380 KB Output is correct
41 Correct 76 ms 2624 KB Output is correct
42 Correct 75 ms 2440 KB Output is correct
43 Correct 73 ms 2300 KB Output is correct
44 Correct 79 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 2424 KB Output is correct
2 Correct 59 ms 2604 KB Output is correct
3 Correct 72 ms 2384 KB Output is correct
4 Correct 59 ms 2364 KB Output is correct
5 Correct 53 ms 2440 KB Output is correct
6 Correct 52 ms 2220 KB Output is correct
7 Correct 57 ms 2388 KB Output is correct
8 Correct 56 ms 2544 KB Output is correct
9 Correct 55 ms 2524 KB Output is correct
10 Correct 59 ms 2596 KB Output is correct
11 Correct 55 ms 2556 KB Output is correct
12 Correct 57 ms 2544 KB Output is correct
13 Correct 57 ms 2588 KB Output is correct
14 Correct 57 ms 2384 KB Output is correct
15 Correct 56 ms 2388 KB Output is correct
16 Correct 57 ms 2388 KB Output is correct
17 Correct 55 ms 2360 KB Output is correct
18 Correct 75 ms 2284 KB Output is correct
19 Correct 5061 ms 37388 KB Output is correct
20 Execution timed out 7011 ms 36292 KB Time limit exceeded
21 Halted 0 ms 0 KB -