AtCoder Beginner Contest 055

Submission #1358834

Source codeソースコード

#include <bits/stdc++.h>
using namespace std;

const int DIM = 1e5 + 5;

string str;
bool ans[DIM];

int main( void ) {
    
    int n;
    cin >> n >> str;
    
    for( char &ch : str )
        ch = ( ch == 'x' );
    
    bool ok = false;
    for( int v0 = 0; v0 <= 1 && ok == false; v0 ++ ) {
    for( int v1 = 0; v1 <= 1 && ok == false; v1 ++ ) {
        ans[0] = v0; ans[1] = v1;
        
        for( int i = 2; i < n; i ++ )
            ans[i] = ( ans[i - 2] ^ ans[i - 1] ^ str[i - 1] );
        
        if( ( ans[n - 2] ^ ans[n - 1] ^ str[n - 1] ) == ans[0] &&
            ( ans[1] ^ ans[0] ^ str[0] ) == ans[n - 1] ) ok = true;
    } }

    if( ok == false )
        cout << -1 << endl;
    else {
        for( int i = 0; i < n; i ++ )
            cout << ( ans[i] == 0 ? 'S' : 'W' );
        cout << endl;
    }
    
    return 0;
}

Submission

Task問題 D - Menagerie
User nameユーザ名 EmanuelNrx
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 500
Source lengthソースコード長 881 Byte
File nameファイル名
Exec time実行時間 9 ms
Memory usageメモリ使用量 640 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - 00_example_01.txt,00_example_02.txt,00_example_03.txt
All 500 / 500 00_example_01.txt,00_example_02.txt,00_example_03.txt,01.txt,02.txt,03.txt,04.txt,05.txt,06.txt,07.txt,08.txt,09.txt,10.txt,11.txt,12.txt,13.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_example_01.txt AC 1 ms 256 KB
00_example_02.txt AC 1 ms 256 KB
00_example_03.txt AC 1 ms 256 KB
01.txt AC 6 ms 512 KB
02.txt AC 4 ms 512 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 8 ms 640 KB
06.txt AC 7 ms 640 KB
07.txt AC 2 ms 256 KB
08.txt AC 2 ms 384 KB
09.txt AC 2 ms 256 KB
10.txt AC 2 ms 256 KB
11.txt AC 9 ms 640 KB
12.txt AC 9 ms 640 KB
13.txt AC 8 ms 640 KB