답안 #750964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750964 2023-05-30T16:49:33 Z joelgun14 Crossing (JOI21_crossing) C++17
26 / 100
7000 ms 1916 KB
// header file
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// pragma
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
// macros
#define endl "\n"
#define ll long long
#define mp make_pair
#define ins insert
#define lb lower_bound
#define pb push_back
#define ub upper_bound
#define lll __int128
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
string operate(string a, string b) {
    for(int it = 0; it < a.size(); ++it) {
        if(a[it] == b[it])
            continue;
        bool j = 0, o = 0, i = 0;
        if(a[it] == 'J')
            j = 1;
        else if(a[it] == 'O')
            o = 1;
        else
            i = 1;
        if(b[it] == 'J')
            j = 1;
        else if(b[it] == 'O')
            o = 1;
        else
            i = 1;
        if(!j)
            a[it] = 'J';
        else if(!o)
            a[it] = 'O';
        else
            a[it] = 'I';
    }
    return a;
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int n;
    cin >> n;
    // coba cek tiap possibility pengambilan
    // max pengambilan cmn 3?
    string a[3];
    cin >> a[0] >> a[1] >> a[2];
    int q;
    cin >> q;
    string init;
    cin >> init;
    bool ans = 0;
    for(int i = 0; i < 3; ++i) {
        string tmp = a[i];
        if(tmp == init)
            ans = 1;
        for(int j = 0; j < 3; ++j) {
            // lakuin operasi antara a[i] dan a[j];
            tmp = operate(tmp, a[j]);
            if(tmp == init)
                ans = 1;
            for(int k = 0; k < 3; ++k) {
                tmp = operate(tmp, a[k]);
                if(tmp == init)
                    ans = 1;
            }
        }
    }
    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    // coba permutasi size 1, 2, 3
    while(q--) {
        int l, r;
        char x;
        cin >> l >> r >> x;
        for(int i = l - 1; i <= r - 1; ++i)
            init[i] = x;
        bool ans = 0;
        for(int i = 0; i < 3; ++i) {
            string tmp = a[i];
            if(tmp == init)
                ans = 1;
            for(int j = 0; j < 3; ++j) {
                // lakuin operasi antara a[i] dan a[j];
                tmp = operate(tmp, a[j]);
                if(tmp == init)
                    ans = 1;
                for(int k = 0; k < 3; ++k) {
                    tmp = operate(tmp, a[k]);
                    if(tmp == init)
                        ans = 1;
                }
            }
        }
        if(ans)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

Compilation message

Main.cpp: In function 'std::string operate(std::string, std::string)':
Main.cpp:24:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int it = 0; it < a.size(); ++it) {
      |                     ~~~^~~~~~~~~~
Main.cpp:27:28: warning: variable 'i' set but not used [-Wunused-but-set-variable]
   27 |         bool j = 0, o = 0, i = 0;
      |                            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 874 ms 936 KB Output is correct
2 Correct 970 ms 848 KB Output is correct
3 Correct 1008 ms 1008 KB Output is correct
4 Correct 1010 ms 880 KB Output is correct
5 Correct 928 ms 820 KB Output is correct
6 Correct 893 ms 912 KB Output is correct
7 Correct 889 ms 1096 KB Output is correct
8 Correct 1038 ms 952 KB Output is correct
9 Correct 977 ms 908 KB Output is correct
10 Correct 973 ms 880 KB Output is correct
11 Correct 955 ms 916 KB Output is correct
12 Correct 975 ms 1012 KB Output is correct
13 Correct 964 ms 828 KB Output is correct
14 Correct 983 ms 880 KB Output is correct
15 Correct 1000 ms 884 KB Output is correct
16 Correct 958 ms 984 KB Output is correct
17 Correct 1066 ms 880 KB Output is correct
18 Correct 1061 ms 1052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 874 ms 936 KB Output is correct
2 Correct 970 ms 848 KB Output is correct
3 Correct 1008 ms 1008 KB Output is correct
4 Correct 1010 ms 880 KB Output is correct
5 Correct 928 ms 820 KB Output is correct
6 Correct 893 ms 912 KB Output is correct
7 Correct 889 ms 1096 KB Output is correct
8 Correct 1038 ms 952 KB Output is correct
9 Correct 977 ms 908 KB Output is correct
10 Correct 973 ms 880 KB Output is correct
11 Correct 955 ms 916 KB Output is correct
12 Correct 975 ms 1012 KB Output is correct
13 Correct 964 ms 828 KB Output is correct
14 Correct 983 ms 880 KB Output is correct
15 Correct 1000 ms 884 KB Output is correct
16 Correct 958 ms 984 KB Output is correct
17 Correct 1066 ms 880 KB Output is correct
18 Correct 1061 ms 1052 KB Output is correct
19 Execution timed out 7001 ms 1916 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 874 ms 936 KB Output is correct
2 Correct 970 ms 848 KB Output is correct
3 Correct 1008 ms 1008 KB Output is correct
4 Correct 1010 ms 880 KB Output is correct
5 Correct 928 ms 820 KB Output is correct
6 Correct 893 ms 912 KB Output is correct
7 Correct 889 ms 1096 KB Output is correct
8 Correct 1038 ms 952 KB Output is correct
9 Correct 977 ms 908 KB Output is correct
10 Correct 973 ms 880 KB Output is correct
11 Correct 955 ms 916 KB Output is correct
12 Correct 975 ms 1012 KB Output is correct
13 Correct 964 ms 828 KB Output is correct
14 Correct 983 ms 880 KB Output is correct
15 Correct 1000 ms 884 KB Output is correct
16 Correct 958 ms 984 KB Output is correct
17 Correct 1066 ms 880 KB Output is correct
18 Correct 1061 ms 1052 KB Output is correct
19 Correct 2409 ms 764 KB Output is correct
20 Correct 2712 ms 868 KB Output is correct
21 Correct 1891 ms 812 KB Output is correct
22 Correct 1262 ms 840 KB Output is correct
23 Correct 1957 ms 796 KB Output is correct
24 Correct 1670 ms 880 KB Output is correct
25 Correct 1995 ms 788 KB Output is correct
26 Correct 1369 ms 864 KB Output is correct
27 Correct 2278 ms 920 KB Output is correct
28 Correct 1736 ms 784 KB Output is correct
29 Correct 2124 ms 1076 KB Output is correct
30 Correct 1395 ms 852 KB Output is correct
31 Correct 2706 ms 896 KB Output is correct
32 Correct 2463 ms 896 KB Output is correct
33 Correct 2801 ms 972 KB Output is correct
34 Correct 1875 ms 968 KB Output is correct
35 Correct 2619 ms 792 KB Output is correct
36 Correct 2739 ms 884 KB Output is correct
37 Correct 2675 ms 976 KB Output is correct
38 Correct 2421 ms 908 KB Output is correct
39 Correct 2560 ms 884 KB Output is correct
40 Correct 2459 ms 880 KB Output is correct
41 Correct 2429 ms 972 KB Output is correct
42 Correct 2547 ms 864 KB Output is correct
43 Correct 2049 ms 1000 KB Output is correct
44 Correct 2573 ms 880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 874 ms 936 KB Output is correct
2 Correct 970 ms 848 KB Output is correct
3 Correct 1008 ms 1008 KB Output is correct
4 Correct 1010 ms 880 KB Output is correct
5 Correct 928 ms 820 KB Output is correct
6 Correct 893 ms 912 KB Output is correct
7 Correct 889 ms 1096 KB Output is correct
8 Correct 1038 ms 952 KB Output is correct
9 Correct 977 ms 908 KB Output is correct
10 Correct 973 ms 880 KB Output is correct
11 Correct 955 ms 916 KB Output is correct
12 Correct 975 ms 1012 KB Output is correct
13 Correct 964 ms 828 KB Output is correct
14 Correct 983 ms 880 KB Output is correct
15 Correct 1000 ms 884 KB Output is correct
16 Correct 958 ms 984 KB Output is correct
17 Correct 1066 ms 880 KB Output is correct
18 Correct 1061 ms 1052 KB Output is correct
19 Execution timed out 7001 ms 1916 KB Time limit exceeded
20 Halted 0 ms 0 KB -