Submission #63022479
Source Code Expand
Copy
#include<bits/stdc++.h>using namespace std;#define ll long longint main(){string s;cin>>s;int len=0,idx=0;string ans="";for(int i=0;i<s.size();i++){if(s[i]=='W') {// if(len=0) idx=i;len++;if(s[i+1]=='A'){ans+="A";for(int j=1;j<=len;j++) ans+="C";len=0;i++;}else if(s[i+1]!='A' && s[i+1]!='W') {for(int j=1;j<=len;j++) ans+="W";len=0;
#include<bits/stdc++.h> using namespace std; #define ll long long int main(){ string s; cin>>s; int len=0,idx=0; string ans=""; for(int i=0;i<s.size();i++){ if(s[i]=='W') { // if(len=0) idx=i; len++; if(s[i+1]=='A'){ ans+="A"; for(int j=1;j<=len;j++) ans+="C"; len=0; i++; } else if(s[i+1]!='A' && s[i+1]!='W') { for(int j=1;j<=len;j++) ans+="W"; len=0; } } else { len=0; ans+=s[i]; } } if(len!=0) { for(int i=1;i<=len;i++) ans+="W"; } cout<<ans; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Debug |
User | zhepei |
Language | C++ 20 (gcc 12.2) |
Score | 300 |
Code Size | 559 Byte |
Status | AC |
Exec Time | 6 ms |
Memory | 4300 KB |
Compile Error
Main.cpp: In function ‘int main()’: Main.cpp:9:22: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare] 9 | for(int i=0;i<s.size();i++){ | ~^~~~~~~~~ Main.cpp:7:19: warning: unused variable ‘idx’ [-Wunused-variable] 7 | int len=0,idx=0; | ^~~
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_00.txt, example_01.txt, example_02.txt |
All | example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
example_00.txt | AC | 1 ms | 3436 KB |
example_01.txt | AC | 1 ms | 3500 KB |
example_02.txt | AC | 1 ms | 3528 KB |
hand_00.txt | AC | 6 ms | 4132 KB |
hand_01.txt | AC | 6 ms | 4176 KB |
hand_02.txt | AC | 6 ms | 4192 KB |
hand_03.txt | AC | 6 ms | 4076 KB |
hand_04.txt | AC | 1 ms | 3528 KB |
hand_05.txt | AC | 1 ms | 3648 KB |
hand_06.txt | AC | 6 ms | 4140 KB |
random_00.txt | AC | 6 ms | 4144 KB |
random_01.txt | AC | 6 ms | 4072 KB |
random_02.txt | AC | 6 ms | 4200 KB |
random_03.txt | AC | 6 ms | 4148 KB |
random_04.txt | AC | 6 ms | 4176 KB |
random_05.txt | AC | 6 ms | 4136 KB |
random_06.txt | AC | 6 ms | 4200 KB |
random_07.txt | AC | 6 ms | 4064 KB |
random_08.txt | AC | 6 ms | 4152 KB |
random_09.txt | AC | 6 ms | 4132 KB |
random_10.txt | AC | 6 ms | 4152 KB |
random_11.txt | AC | 6 ms | 4084 KB |
random_12.txt | AC | 6 ms | 4172 KB |
random_13.txt | AC | 6 ms | 4132 KB |
random_14.txt | AC | 6 ms | 4300 KB |
random_15.txt | AC | 6 ms | 4092 KB |
random_16.txt | AC | 6 ms | 4156 KB |
random_17.txt | AC | 6 ms | 4104 KB |
random_18.txt | AC | 6 ms | 4140 KB |
random_19.txt | AC | 6 ms | 4296 KB |