답안 #851253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
851253 2023-09-19T07:18:15 Z LucaIlie Crossing (JOI21_crossing) C++17
26 / 100
7000 ms 5804 KB
#include <bits/stdc++.h>

using namespace std;


char other( char a, char b ) {
    if ( a != 'J' && b != 'J' )
        return 'J';
    if ( a != 'O' && b != 'O' )
        return 'O';
    return 'I';
}

string combine( string a, string b ) {
    string ans;
    ans.resize( a.size() );
    for ( int i = 0; i < a.size(); i++ )
        ans[i] = (a[i] == b[i] ? a[i] : other( a[i], b[i] ) );
    return ans;
}

set<string> s;

int main() {
    int n, q;
    string s1, s2, s3, t;

    cin >> n >> s1 >> s2 >> s3;

    s.insert( s1 );
    s.insert( s2 );
    s.insert( s3 );
    bool isNew = true;
    while ( isNew ) {
        isNew = false;
        set<string> newS;
        for ( string x: s ) {
            string y1 = combine( x, s1 );
            string y2 = combine( x, s2 );
            string y3 = combine( x, s3 );

            if ( s.find( y1 ) == s.end() && newS.find( y1 ) == newS.end() ) {
                isNew = true;
                newS.insert( y1 );
            }
            if ( s.find( y2 ) == s.end() && newS.find( y2 ) == newS.end() ) {
                isNew = true;
                newS.insert( y2 );
            }
            if ( s.find( y3 ) == s.end() && newS.find( y3 ) == newS.end() ) {
                isNew = true;
                newS.insert( y3 );
            }
        }

        for ( string x: newS )
            s.insert( x );
    }

    cin >> q >> t;
    cout << ((s.find( t ) != s.end()) ? "Yes\n" : "No\n");
    while ( q-- ) {
        int l, r;
        char ch;

        cin >> l >> r >> ch;
        l--;
        r--;
        for ( int i = l; i <= r; i++ )
            t[i] = ch;

        cout << ((s.find( t ) != s.end()) ? "Yes\n" : "No\n");
    }

    return 0;
}

Compilation message

Main.cpp: In function 'std::string combine(std::string, std::string)':
Main.cpp:17:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for ( int i = 0; i < a.size(); i++ )
      |                      ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 276 ms 2344 KB Output is correct
2 Correct 300 ms 2460 KB Output is correct
3 Correct 306 ms 2356 KB Output is correct
4 Correct 311 ms 2340 KB Output is correct
5 Correct 285 ms 2388 KB Output is correct
6 Correct 296 ms 2380 KB Output is correct
7 Correct 291 ms 2432 KB Output is correct
8 Correct 311 ms 2408 KB Output is correct
9 Correct 295 ms 2392 KB Output is correct
10 Correct 303 ms 2528 KB Output is correct
11 Correct 301 ms 2548 KB Output is correct
12 Correct 295 ms 2752 KB Output is correct
13 Correct 296 ms 2544 KB Output is correct
14 Correct 295 ms 2408 KB Output is correct
15 Correct 296 ms 2404 KB Output is correct
16 Correct 314 ms 2384 KB Output is correct
17 Correct 294 ms 2552 KB Output is correct
18 Correct 319 ms 2256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 276 ms 2344 KB Output is correct
2 Correct 300 ms 2460 KB Output is correct
3 Correct 306 ms 2356 KB Output is correct
4 Correct 311 ms 2340 KB Output is correct
5 Correct 285 ms 2388 KB Output is correct
6 Correct 296 ms 2380 KB Output is correct
7 Correct 291 ms 2432 KB Output is correct
8 Correct 311 ms 2408 KB Output is correct
9 Correct 295 ms 2392 KB Output is correct
10 Correct 303 ms 2528 KB Output is correct
11 Correct 301 ms 2548 KB Output is correct
12 Correct 295 ms 2752 KB Output is correct
13 Correct 296 ms 2544 KB Output is correct
14 Correct 295 ms 2408 KB Output is correct
15 Correct 296 ms 2404 KB Output is correct
16 Correct 314 ms 2384 KB Output is correct
17 Correct 294 ms 2552 KB Output is correct
18 Correct 319 ms 2256 KB Output is correct
19 Correct 3513 ms 5804 KB Output is correct
20 Execution timed out 7009 ms 3728 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 276 ms 2344 KB Output is correct
2 Correct 300 ms 2460 KB Output is correct
3 Correct 306 ms 2356 KB Output is correct
4 Correct 311 ms 2340 KB Output is correct
5 Correct 285 ms 2388 KB Output is correct
6 Correct 296 ms 2380 KB Output is correct
7 Correct 291 ms 2432 KB Output is correct
8 Correct 311 ms 2408 KB Output is correct
9 Correct 295 ms 2392 KB Output is correct
10 Correct 303 ms 2528 KB Output is correct
11 Correct 301 ms 2548 KB Output is correct
12 Correct 295 ms 2752 KB Output is correct
13 Correct 296 ms 2544 KB Output is correct
14 Correct 295 ms 2408 KB Output is correct
15 Correct 296 ms 2404 KB Output is correct
16 Correct 314 ms 2384 KB Output is correct
17 Correct 294 ms 2552 KB Output is correct
18 Correct 319 ms 2256 KB Output is correct
19 Correct 295 ms 2792 KB Output is correct
20 Correct 308 ms 2312 KB Output is correct
21 Correct 300 ms 2652 KB Output is correct
22 Correct 273 ms 2200 KB Output is correct
23 Correct 297 ms 2388 KB Output is correct
24 Correct 284 ms 2468 KB Output is correct
25 Correct 322 ms 2828 KB Output is correct
26 Correct 289 ms 2340 KB Output is correct
27 Correct 295 ms 2512 KB Output is correct
28 Correct 286 ms 2600 KB Output is correct
29 Correct 309 ms 2548 KB Output is correct
30 Correct 278 ms 2404 KB Output is correct
31 Correct 309 ms 2344 KB Output is correct
32 Correct 303 ms 2636 KB Output is correct
33 Correct 298 ms 2480 KB Output is correct
34 Correct 286 ms 2308 KB Output is correct
35 Correct 325 ms 2384 KB Output is correct
36 Correct 308 ms 2640 KB Output is correct
37 Correct 296 ms 2384 KB Output is correct
38 Correct 300 ms 2548 KB Output is correct
39 Correct 298 ms 2504 KB Output is correct
40 Correct 296 ms 2384 KB Output is correct
41 Correct 299 ms 2536 KB Output is correct
42 Correct 304 ms 2388 KB Output is correct
43 Correct 304 ms 2320 KB Output is correct
44 Correct 301 ms 2408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 276 ms 2344 KB Output is correct
2 Correct 300 ms 2460 KB Output is correct
3 Correct 306 ms 2356 KB Output is correct
4 Correct 311 ms 2340 KB Output is correct
5 Correct 285 ms 2388 KB Output is correct
6 Correct 296 ms 2380 KB Output is correct
7 Correct 291 ms 2432 KB Output is correct
8 Correct 311 ms 2408 KB Output is correct
9 Correct 295 ms 2392 KB Output is correct
10 Correct 303 ms 2528 KB Output is correct
11 Correct 301 ms 2548 KB Output is correct
12 Correct 295 ms 2752 KB Output is correct
13 Correct 296 ms 2544 KB Output is correct
14 Correct 295 ms 2408 KB Output is correct
15 Correct 296 ms 2404 KB Output is correct
16 Correct 314 ms 2384 KB Output is correct
17 Correct 294 ms 2552 KB Output is correct
18 Correct 319 ms 2256 KB Output is correct
19 Correct 3513 ms 5804 KB Output is correct
20 Execution timed out 7009 ms 3728 KB Time limit exceeded
21 Halted 0 ms 0 KB -