Submission #3427035
Source Code Expand
#include<bits/stdc++.h> #define FOR(i,n) for(int i=0;i<n;i++) #define SFOR(i,a,b) for(int i=a;i<b;i++) #define elif(a) else if(a) #define INF INT_MAX #define F first #define S second #define endl '\n' using namespace std; typedef long long ll; typedef pair<int,int>P; string a; int j,flag,cnt; int main(){ cin.tie(0); ios::sync_with_stdio(false); cin>>a; if(a.size()==1){ cout<<"0"<<endl; return 0; } while(1){ FOR(i,a.size()-1){ if(a[i]!=a[i+1]) break; if(i==a.size()-2) flag=1; } char f; if(flag) break; if(a[a.size()-1]=='B'){ a+='W'; f='W'; }else{ a+='B'; f='B'; } for(j=a.size()-2;a[j]!=f;j--){ if(a[j]=='B') a[j]='W'; else a[j]='B'; } cnt++; } cout<<cnt<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 1D Reversi |
User | ei1704 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 839 Byte |
Status | TLE |
Exec Time | 2103 ms |
Memory | 512 KB |
Judge Result
Set Name | sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | alternate_01.txt, alternate_02.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, same_01.txt, same_02.txt, sample_01.txt, sample_02.txt, sample_03.txt, small_01.txt, small_02.txt, small_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
alternate_01.txt | TLE | 2103 ms | 512 KB |
alternate_02.txt | TLE | 2103 ms | 512 KB |
random_01.txt | TLE | 2103 ms | 512 KB |
random_02.txt | TLE | 2103 ms | 512 KB |
random_03.txt | TLE | 2103 ms | 512 KB |
random_04.txt | TLE | 2103 ms | 512 KB |
random_05.txt | AC | 1838 ms | 512 KB |
same_01.txt | AC | 1 ms | 512 KB |
same_02.txt | AC | 1 ms | 512 KB |
sample_01.txt | AC | 1 ms | 256 KB |
sample_02.txt | AC | 1 ms | 256 KB |
sample_03.txt | AC | 1 ms | 256 KB |
small_01.txt | AC | 1 ms | 256 KB |
small_02.txt | AC | 1 ms | 256 KB |
small_03.txt | AC | 1 ms | 256 KB |