Submission #1347627
Source Code Expand
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define INF 1e9+7
#define pf2 pop_front
#define pb2 pop_back
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order
#define fastio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key
#define val(x) cout << "Value dari "<< #x << " adalah " << x << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void readf(string x){
freopen((x+".in").c_str(),"r",stdin);
freopen((x+".out").c_str(),"w",stdout);
}
void pr(string x){
freopen((x+".in").c_str(),"w",stdout);
}
int read()
{
bool min = 0;
int result = 0;
char ch;
ch = getchar();
while(1)
{
if(ch == '-') break;
if(ch >='0' && ch <= '9') break;
ch = getchar();
}
if(ch == '-') min = 1;else result = ch-'0';
while(1)
{
ch =getchar();
if(ch< '0' || ch>'9') break;
result = result * 10 + (ch-'0');
}
if(min) return -result;
return result;
}
//Reynaldo's Template
int main(){
int N;
cin >> N;
string y;
cin >> y;
int x[N+5];
for(int i=0;i<(1<<2);i++){
if(1 & i) x[1] = 0;
else x[1] = 1;
if(2 & i) x[2] = 0;
else x[2] = 1;
bool ok = 0;
for(int j=2;j<=N;j++){
int a;
if(y[j-1] == 'o'){
if(x[j] == 0){
a = x[j-1] ^ 1;
}
else{
a = x[j-1];
}
}
else{
if(x[j] == 1){
a = x[j-1] ^ 1;
}
else{
a = x[j-1];
}
}
if(j == N){
if(a != x[1]){
ok = 1;
break;
}
}
x[j+1] = a;
}
// cout << x[1] << " " << x[2] << " " << x[N] << " " << y[0] << "\n";
if(x[1] == 1){ // 1 harus sama
if(y[0] == 'o'){
if(x[N] != x[2]) {
continue;
// break;
}
}
else{
if(x[N] == x[2]) {
continue;
}
}
}
else{
if(y[0] == 'o')
if(x[N] == x[2]){ // 0 harus beda
// break;
continue;
}
else{
if(x[N] != x[2]) continue;
}
}
if(!ok){
for(int j=1;j<=N;j++){
if(x[j] == 1) {
cout << "S";
}
else cout << "W";
}
cout << "\n";
return 0;
}
}
cout << -1 << "\n";
}
Submission Info
Submission Time |
|
Task |
D - Menagerie |
User |
rwhendry |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2413 Byte |
Status |
WA |
Exec Time |
9 ms |
Memory |
896 KB |
Compile Error
./Main.cpp: In function ‘void readf(std::string)’:
./Main.cpp:26:38: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
freopen((x+".in").c_str(),"r",stdin);
^
./Main.cpp:27:40: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
freopen((x+".out").c_str(),"w",stdout);
^
./Main.cpp: In function ‘void pr(std::string)’:
./Main.cpp:31:39: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
freopen((x+".in").c_str(),"w",stdout);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
All |
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 |
Case Name |
Status |
Exec Time |
Memory |
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 |
WA |
6 ms |
640 KB |
02.txt |
AC |
5 ms |
640 KB |
03.txt |
AC |
1 ms |
256 KB |
04.txt |
AC |
2 ms |
256 KB |
05.txt |
WA |
6 ms |
768 KB |
06.txt |
AC |
9 ms |
896 KB |
07.txt |
WA |
3 ms |
384 KB |
08.txt |
WA |
3 ms |
384 KB |
09.txt |
AC |
2 ms |
256 KB |
10.txt |
WA |
3 ms |
384 KB |
11.txt |
WA |
8 ms |
896 KB |
12.txt |
WA |
8 ms |
896 KB |
13.txt |
WA |
7 ms |
896 KB |