submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s687295854 | p03797 | C | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define print printf("%ld", answer)
int main(void){
longlong N, M, answer, k, l;
scanf("%ld", &N);
scanf("%ld", &M);
if(N>=0&&M<=1000000000000)
{
if(M%2==0)
{
k = M/2;
if(N>=k)
{
answer = k;
}
if(N==k-1)
{
answer = N;
}
if(N<=k-2)
{
if(k%2==0)
{
l = k/2;
answer = N + l;
}
if(k%2==1)
{
l = (k-1)/2;
answer = N + l;
}
}
}
if(M%2==1)
{
k = (M+1)/2;
if(N>=k-1)
{
answer=k-1;
}
if(N==k-2)
{
answer = N;
}
else
{
if((k-1-N)%2==0)
{
l = (k-1-N)/2;
answer = N + l;
}
else
{
l = (k-2-N)/2;
answer = N + l;
}
}
}
print;
}
return 0;
}
| main.c: In function 'main':
main.c:7:3: error: unknown type name 'longlong'
7 | longlong N, M, answer, k, l;
| ^~~~~~~~
|
s632775343 | p03797 | C | #include<stdio.h>
int main()
{
int snum,cnum,ans;
ans=0
scanf("%d %d",&snum,&cnum);
if(snum*2>cnum) {
ans+=(int)(cnum/2);
}else{
ans+=(int)((cnum-snum*2)/4)+snum;
}
printf("%d\n",ans);
return 0;
} | main.c: In function 'main':
main.c:6:14: error: expected ';' before 'scanf'
6 | ans=0
| ^
| ;
7 | scanf("%d %d",&snum,&cnum);
| ~~~~~
|
s667624569 | p03797 | C | #include<stdio.h>
int main()
{
int snum,cnum,ans;
scanf("%d %d",&snum,&cnum);
if(snum>=cnum*2) ans=snum;
if(snum<cnum*2) ans=(int)((snum-2cnum)/3)+snum;
printf("%d\n",ans);
return 0;
} | main.c: In function 'main':
main.c:8:41: error: invalid suffix "cnum" on integer constant
8 | if(snum<cnum*2) ans=(int)((snum-2cnum)/3)+snum;
| ^~~~~
|
s946029142 | p03797 | C | #include<stdio.h>
int main()
{
int N,M,ans;
scanf("%d %d",&N,&M);
if(N>=M*2) ans=N;
if(N<M*2) ans=(int)((M-2N)/3)+N;
printf("%d",ans);
return 0;
} | main.c: In function 'main':
main.c:8:32: error: invalid suffix "N" on integer constant
8 | if(N<M*2) ans=(int)((M-2N)/3)+N;
| ^~
|
s546137169 | p03797 | C | #include<stdio.h>
int main()
{
int N,M,ans;
scanf("%d %d",N,M);
if(N>=M*2) ans=N;
if(N<M*2) ans=(int)((M-2N)/3)+N;
printf("%d",ans);
return 0;
} | main.c: In function 'main':
main.c:8:32: error: invalid suffix "N" on integer constant
8 | if(N<M*2) ans=(int)((M-2N)/3)+N;
| ^~
|
s823796020 | p03797 | C | #include<stdio.h>
Int main()
{
int N,M,ans;
scanf("%d %d",N,M);
if(N>=M*2) ans=N;
if(N<M*2) ans=(M-2N)/3+N;
printf("%d",ans);
return 0;
} | main.c:3:1: error: unknown type name 'Int'; did you mean 'int'?
3 | Int main()
| ^~~
| int
main.c: In function 'main':
main.c:8:26: error: invalid suffix "N" on integer constant
8 | if(N<M*2) ans=(M-2N)/3+N;
| ^~
|
s237205345 | p03797 | Java | import java.util.Scanner;
class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
long a = scan.nextlong();
long b = scan.nextlong();
long c = b-a*2;
long d = c/4;
System.out.println(a+d);
}
} | Main.java:5: error: cannot find symbol
long a = scan.nextlong();
^
symbol: method nextlong()
location: variable scan of type Scanner
Main.java:6: error: cannot find symbol
long b = scan.nextlong();
^
symbol: method nextlong()
location: variable scan of type Scanner
2 errors
|
s298755765 | p03797 | C++ | #include <iostream>
int main() {
int N;
std::cin >> N;
int remainder = 1;
for (int i = 1; i <= N; i++) {
remainder = remainder * i
remainder %= 10e+9 +7;
}
std::cout << remainder << std::endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:8:28: error: expected ';' before 'remainder'
8 | remainder = remainder * i
| ^
| ;
9 | remainder %= 10e+9 +7;
| ~~~~~~~~~
|
s778609894 | p03797 | C++ | #include <iostream>
using namespace std;
int N, M;
int main(){
cin >> N >> M;
// long long int ns = N;
// long long int rc = M - N * 2;
// while(rc < 0){
// ns --;
// rc = M - rc*2;
// }
long long int ns = min(N, M/2);
long long int rs = m - ns * 2;
ns += rc / 4;
cout << ns << endl;
}
| a.cc: In function 'int main()':
a.cc:14:28: error: 'm' was not declared in this scope
14 | long long int rs = m - ns * 2;
| ^
a.cc:15:15: error: 'rc' was not declared in this scope; did you mean 'rs'?
15 | ns += rc / 4;
| ^~
| rs
|
s182420440 | p03797 | C++ | #include <iostream>
using namespace std;
int main()
{
__int64 N, M, cnt = 0;
cin >> N >> M;
if (N >= M * 2)
cnt = N;
else
cnt = N + (M - 2 * N) / 4;
cout << cnt << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:6:9: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
6 | __int64 N, M, cnt = 0;
| ^~~~~~~
| __int64_t
a.cc:7:16: error: 'N' was not declared in this scope
7 | cin >> N >> M;
| ^
a.cc:7:21: error: 'M' was not declared in this scope
7 | cin >> N >> M;
| ^
a.cc:10:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
10 | cnt = N;
| ^~~
| int
a.cc:12:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
12 | cnt = N + (M - 2 * N) / 4;
| ^~~
| int
a.cc:14:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
14 | cout << cnt << endl;
| ^~~
| int
|
s639050893 | p03797 | C++ | #include<iostream>
using namespace std;
int main(){
long long a,b;
std::cin>>a>>b;
if(a=>(b/2)){
std::cout<<(b/2);
}else{
std::cout<<(a+((b-2a)/4));
}
} | a.cc: In function 'int main()':
a.cc:6:14: error: expected primary-expression before '>' token
6 | if(a=>(b/2)){
| ^
a.cc:9:35: error: unable to find numeric literal operator 'operator""a'
9 | std::cout<<(a+((b-2a)/4));
| ^~
|
s107618413 | p03797 | C++ | #include<iostream>
int main ()
{
long long int n,m;
//std::string s;
std::cin>>n >> m /*>>c>>s*/;
if (2*n>=m)
{
long long int j;
j=m/2
stdu:cout<<j /*<< " "*/ <<std::endl;
}
else
{
long long int k;
k=(m-2*n)/4;
std::cout<<k+n /*<< " " << s */<<std::endl;
}
//std::cout<<d << " " << s <<std::endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:12:16: error: expected ';' before 'stdu'
12 | j=m/2
| ^
| ;
13 | stdu:cout<<j /*<< " "*/ <<std::endl;
| ~~~~
|
s571890486 | p03797 | Java | public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long s = sc.nextInt();
long c = sc.nextInt();
long result = 0;
if (c <= s * 2) {
result = Math.round(c / 2);
c = c % 2;
} else {
result = s;
c = c - s * 2;
result = result + c / 4;
}
System.out.println(result);
sc.close();
}
} | Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s183556912 | p03797 | C++ | let id x = x
let (n,m) = Scanf.scanf "%d %d\n" (fun n m -> (n,m))
let sc s c x =
if (2*s) <= c then ((c-2*s),s) else (0,c/2)
let cx = sc n m 0
let c = fst cx
let x = snd cx
let ans = x + c/4
let () = Printf.printf "%d\n" ans | a.cc:1:1: error: 'let' does not name a type
1 | let id x = x
| ^~~
|
s801924278 | p03797 | C | #include <stdio.h>
int main ()
{
int ans=0,n,m,i;
scanf("%d%d",&n,&m);
ans=n;
if(n*2<m)
{
while(m-4>0)
{
m-=4;
ans++;
}
printf("%d",ans);
return 0;
}
| main.c: In function 'main':
main.c:18:1: error: expected declaration or statement at end of input
18 | }
| ^
|
s431938799 | p03797 | C++ | #include<stdio.h>
#include<stdlib.h>
long long int n,m,a,b,c;
int main(void){
scanf("%lld",n);
scanf("%lld",m);
a = n - m / 2;
if(a < 0){
b = a / 4
}else{
b = n
}
printf("%lld",b)
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:11: error: expected ';' before '}' token
11 | b = a / 4
| ^
| ;
12 | }else{
| ~
a.cc:13:6: error: expected ';' before '}' token
13 | b = n
| ^
| ;
14 | }
| ~
a.cc:15:17: error: expected ';' before 'return'
15 | printf("%lld",b)
| ^
| ;
16 |
17 | return 0;
| ~~~~~~
|
s290444804 | p03797 | C++ | #include<stdio.h>
#include<stdlib.h>
long long int n,m,a,b,c;
int main(void){
scanf("%lld",n);
scanf("%lld",m);
a = n - m / 2;
if(a < 0){
b = a / 4
}else{
b = n
}
printf("%lld",b)
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:11: error: expected ';' before '}' token
11 | b = a / 4
| ^
| ;
12 | }else{
| ~
a.cc:13:6: error: expected ';' before '}' token
13 | b = n
| ^
| ;
14 | }
| ~
a.cc:15:17: error: expected ';' before 'return'
15 | printf("%lld",b)
| ^
| ;
16 |
17 | return 0;
| ~~~~~~
|
s936292094 | p03797 | C | #include<stdio.h>
int main()
{
int i,j,n,m;
scanf("%d%d",&n,&m);
if(2*n<=m)
printf("%d",int(n+(m-2*n)*1.0/4));
else printf("%d",int(n-(2*n-m)*1.0/4));
} | main.c: In function 'main':
main.c:7:21: error: expected expression before 'int'
7 | printf("%d",int(n+(m-2*n)*1.0/4));
| ^~~
main.c:8:26: error: expected expression before 'int'
8 | else printf("%d",int(n-(2*n-m)*1.0/4));
| ^~~
|
s170309855 | p03797 | C++ | #include <iostream>
#include <string>
using namespace std;
int main(void){
long long N, M;
cin >> N >> M;
int total = 0;
if(2*N <= M){
total = N + (M - 2 * N) / 4;
}
else{
total = floor(M / 2);
}
cout << total << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:17:17: error: 'floor' was not declared in this scope
17 | total = floor(M / 2);
| ^~~~~
|
s439740975 | p03797 | C++ | #include <iostream>
using namespace std;
int main()
{
long long n;
long long i;
long long o;
cin >> n;
cin >> i;
o = 1;
if (n <= i * 2)
o = n + (i - 2 * n) / 4;
else (i <= n / 2)
o = i / 2;
cout << o << endl;
} | a.cc: In function 'int main()':
a.cc:22:27: error: expected ';' before 'o'
22 | else (i <= n / 2)
| ^
| ;
23 | o = i / 2;
| ~
|
s189137851 | p03797 | C++ | #include <iostream>
using namespace std;
int main()
{
long long n;
long long i;
long long o;
cin >> n;
cin >> i;
o = 1;
if (n <= i * 2)
o = n + (i - 2 * n) / 4;
else if (i =< n / 2)
o = i / 2;
else
o = n;
cout << o << endl;
} | a.cc: In function 'int main()':
a.cc:22:21: error: expected primary-expression before '<' token
22 | else if (i =< n / 2)
| ^
|
s949339359 | p03797 | C++ | #include <iostream>
using namespace std;
int main()
{
long long n;
long long i;
long long o;
cin >> n;
cin >> i;
o = 1;
if (n <= i * 2)
o = n + (i - 2 * n) / 4;
else if (i < n/2)
o=i/2
else
o = n;
cout << o << endl;
} | a.cc: In function 'int main()':
a.cc:23:22: error: expected ';' before 'else'
23 | o=i/2
| ^
| ;
24 |
25 | else
| ~~~~
|
s131199095 | p03797 | C++ | #include <iostream>
using namespace std;
int main() {
int n, m, scc;
cin >> n >> m;
if (n-m/2==0)scc=n;
else if(n-m/2>0)scc=m/2;
else if (n-m/2<0)scc=n+(m-n*2)/4;
cout << scc << '/n';
// your code goes here
return 0;
} | a.cc:3:1: error: extended character is not valid in an identifier
3 |
| ^
a.cc:12:24: warning: multi-character character constant [-Wmultichar]
12 | cout << scc << '/n';
| ^~~~
a.cc:3:1: error: '\U000000a0' does not name a type
3 |
| ^
|
s546831922 | p03797 | C | #include <stdio.h>
int main (void)
{
int i,n,m,ans=0;
scanf("%d%d",&n,&m);
if(n*2>=m)
{
ans+=m/2;
}
else
{
ans+=n;
m=m-n*2;
ans+=m/4
}
printf("%d",&ans);
return 0;
} | main.c: In function 'main':
main.c:17:13: error: expected ';' before '}' token
17 | ans+=m/4
| ^
| ;
18 | }
| ~
|
s527520838 | p03797 | C++ | #include<iostream>
using namespace std;
int main() {
int s, c, x = 0;;
cin >> s >> c;
while(1){
if(s < 1 || c < 2) break;
if (s >= 1 || c >= 2) {
x++;
s -= 1;
c -= 2;
}
}
while(1) {
if(c < 4) break;
if(c >= 4) {
x++;
c -= 4;
}
}
cout << x << endl
return 0;
}
| a.cc: In function 'int main()':
a.cc:25:20: error: expected ';' before 'return'
25 | cout << x << endl
| ^
| ;
26 |
27 | return 0;
| ~~~~~~
|
s846053051 | p03797 | Java | import java.util.Scanner;
/**
* Created by User on 2017/02/18.
*/
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long n = scanner.nextLong();
long m = scanner.nextLong();
int count = 0;
while (n > 0) {
n--;
m -= 2;
count++;
}
while (m >= 4) {
m-=4;
count++;
}
System.out.println(count);
}
}
| Main.java:6: error: illegal character: '\u3000'
public class Main?{
^
1 error
|
s360632772 | p03797 | C++ | #include <iostream>
using namespace std;
int main()
{
_I64_MAX n;
_I64_MAX i;
_I64_MAX o;
cin >> n;
cin >> i;
o = 1;
if (n <= i * 2)
o = n + (i - 2*n) / 4;
else
o = n;
cout << o << endl;
} | a.cc: In function 'int main()':
a.cc:6:9: error: '_I64_MAX' was not declared in this scope
6 | _I64_MAX n;
| ^~~~~~~~
a.cc:8:17: error: expected ';' before 'i'
8 | _I64_MAX i;
| ^~
| ;
a.cc:10:17: error: expected ';' before 'o'
10 | _I64_MAX o;
| ^~
| ;
a.cc:12:16: error: 'n' was not declared in this scope
12 | cin >> n;
| ^
a.cc:13:16: error: 'i' was not declared in this scope
13 | cin >> i;
| ^
a.cc:14:9: error: 'o' was not declared in this scope
14 | o = 1;
| ^
|
s190366236 | p03797 | C | #include<stdio.h>
#include<math.h>
int main(void){
int n,m,k,i=0;
scanf("%d %d",&n,&m);
while(n<m) {
m=m-n*2; i++
}
k=m/4;
printf("%d",i+k);
return 0;
} | main.c: In function 'main':
main.c:9:15: error: expected ';' before '}' token
9 | m=m-n*2; i++
| ^
| ;
10 | }
| ~
|
s606023383 | p03797 | C++ | #include <iostream>
using namespace std;
int main()
{
_I64_MAX n;
_I64_MAX i;
_I64_MAX o;
cin >> n;
cin >> i;
o = 1;
if (n <= i * 2)
o = n + (i - 2*n) / 4;
else
o = n;
cout << o << endl;
} | a.cc: In function 'int main()':
a.cc:6:9: error: '_I64_MAX' was not declared in this scope
6 | _I64_MAX n;
| ^~~~~~~~
a.cc:8:17: error: expected ';' before 'i'
8 | _I64_MAX i;
| ^~
| ;
a.cc:10:17: error: expected ';' before 'o'
10 | _I64_MAX o;
| ^~
| ;
a.cc:12:16: error: 'n' was not declared in this scope
12 | cin >> n;
| ^
a.cc:13:16: error: 'i' was not declared in this scope
13 | cin >> i;
| ^
a.cc:14:9: error: 'o' was not declared in this scope
14 | o = 1;
| ^
|
s714103533 | p03797 | C++ | #include <iostream>
using namespace std;
int main() {
int n, m, scc;
cin >> n >> m;
if (n==m/2)scc=n;
else if (n>m/2)scc=m/2;
else if (n<m/2)scc=n+(m-n*2)/4;
cout << scc << '\n';
// your code goes here
return 0;
} | a.cc:3:1: error: extended character is not valid in an identifier
3 |
| ^
a.cc:3:1: error: '\U000000a0' does not name a type
3 |
| ^
|
s737380864 | p03797 | C++ | #include <iostream>
using namespace std;
int mod = 1000000007;
int main() {
// your code goes here
int N;
cin >> N;
for(long long i= 1,j = 1;i <= N;i++){
j *= i;
j %= mod;
}
cout << j << endl;
int N,M;
cin >> N >> M;
if(N/2 > M){
cout << M+(N-2*M)/4 << endl;
}
else{
cout << N/2 << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:13:17: error: 'j' was not declared in this scope
13 | cout << j << endl;
| ^
a.cc:14:13: error: redeclaration of 'int N'
14 | int N,M;
| ^
a.cc:7:13: note: 'int N' previously declared here
7 | int N;
| ^
|
s253115406 | p03797 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
long long a,b;
long long s=0;
cin>>a>>b;
s+=a;
b-=a*2;
if(b<0)s+=b*2
s+=b/4;
cout<<s<<endl;
} | a.cc: In function 'int main()':
a.cc:9:14: error: expected ';' before 's'
9 | if(b<0)s+=b*2
| ^
| ;
10 | s+=b/4;
| ~
|
s173021573 | p03797 | C++ | #define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int main(){
long long N,M;
cin >> N >> M;
long long ans=0,nokori_c,ans_c;
ans = ans + N;
nokori_c = M - 2*N;
if(nokori_c >= 0){
ans_c = nokori_c/4;
ans = ans + ans_c;
}
else(nokori_c < 0){
ans_c = M/2;
ans = ans + ans_c;
}
if(M < 2){
ans =0;
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:25:27: error: expected ';' before '{' token
25 | else(nokori_c < 0){
| ^
| ;
|
s121322019 | p03797 | Java | import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashSet;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long N = in.nextLong();
long M = in.nextLong();
long result = 0;
if (N == 0 && M == 0) {
result = 0;
} else if (N >= M / 2) {
result = M / 2;
N -= M / 2;
result += N / 2;
} else {
result = N;
M -= 2 * N;
result += M / 4;
}
System.out.println(result);
}
}
ozaw | Main.java:30: error: reached end of file while parsing
ozaw
^
1 error
|
s601429433 | p03797 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
long int n, m;
cin >> n >> m;
if(m<2*n) coutn << m/2 << endl;
else cout << n+((m-2*n)/4) << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:7:15: error: 'coutn' was not declared in this scope
7 | if(m<2*n) coutn << m/2 << endl;
| ^~~~~
|
s849927000 | p03797 | C | #include <stdio.h>
int main (void){
int M,N,a,b,c,d;
scanf("%d %d",&M,&N);
a=2*M+N;
b=(a-a%4)/4;
if (N>=2*b) printf("%d\n",b);
if (N<2*b) {
c=(N-N%2)/2;
printf("%d\n",c);
}
}
return 0; | main.c:13:1: error: expected identifier or '(' before 'return'
13 | return 0;
| ^~~~~~
|
s368419333 | p03797 | C | #include <stdio.h>
int main (void){
int M,N,a,b,c,d;
scanf("%d %d",&M,&N);
a=2*M+N;
b=(a-a%4)/4;
if (N>=2*b) printf("%d\n",b);
if (N<2*b) {
c=(N-N%2)/2;
printf("%d\n",c);
}
}
return 0; | main.c:13:1: error: expected identifier or '(' before 'return'
13 | return 0;
| ^~~~~~
|
s768664370 | p03797 | C++ | #include <stdio.h>
int main (void){
int M,N,a,b,c,d;
scanf("%d %d",&M,&N);
a=2*M+N;
b=(a-a%4)/4;
if (N>=2*b) printf("%d\n",b);
if (N<2*b) {
c=(N-N%2)/2;
printf("%d\n",c);
}
}
return 0; | a.cc:13:1: error: expected unqualified-id before 'return'
13 | return 0;
| ^~~~~~
|
s397849637 | p03797 | C++ | int main() {
long n, m;
std::cin >> n >> m;
long cnt = 0;
while (true) {
if (n >= 1 && m >= 2) {
n--;
m -= 2;
cnt++;
}
else if (n == 0 && m > 2){
n++;
m -= 2;
}
else {
break;
}
}
std::cout << cnt << std::endl;
} | a.cc: In function 'int main()':
a.cc:3:14: error: 'cin' is not a member of 'std'
3 | std::cin >> n >> m;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | int main() {
a.cc:21:14: error: 'cout' is not a member of 'std'
21 | std::cout << cnt << std::endl;
| ^~~~
a.cc:21:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:21:34: error: 'endl' is not a member of 'std'
21 | std::cout << cnt << std::endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 | int main() {
|
s392101479 | p03797 | C++ | #include <stdio.h>
int main (void){
int M,N,a,b,c,d;
scanf("%d %d",&M,&N);
a=2*M+N;
b=(a-a%4)/4;
if (N>=2*b) printf("%d\n",b);
if (N<2*b) {
c=(N-N%2)/2;
printf("%d\n",c);
}
return 0; | a.cc: In function 'int main()':
a.cc:12:10: error: expected '}' at end of input
12 | return 0;
| ^
a.cc:2:16: note: to match this '{'
2 | int main (void){
| ^
|
s381363803 | p03797 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
static const int INF = 1 << 28;
#define D(x) cout << x << endl;
#define d(x) cout << x;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef int long long;
signed main() {
int n, m;
cin >> n >> m;
int s = n;
int ans = 0;
for (int i = 0; i < n; i++) {
if (m > 1) {
s--;
m -= 2;
ans++;
}
}
ans += m / 4;
D(ans);
return 0;
}
| a.cc:24:18: error: declaration does not declare anything [-fpermissive]
24 | typedef int long long;
| ^~~~
|
s792483183 | p03798 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;
int main(){
int N;cin>>N;
string S;cin>>S;
vector<char> A(N+1);
for(int k=0;k<2;++k){
for(int h=0;h<2;++h){
A.clear();
A[0]=(k==0?'S':'W');
A[1]=(h==0?'S':'W');
for(int i=2;i<=N;++i){
if((S[i-1]=='o'&&A[i-1]=='S')||(S[i-1]=='x'&&A[i-1]=='W')){
if(A[i-2]=='S') A[i]='S';
else A[i]='W';
}else if((S[i-1]=='o'&&A[i-1]=='W')||(S[i-1]=='x'&&A[i-1]=='S')){
if(A[i-2]=='S') A[i]='W';
else A[i]='S';
}
}
if(A[0]==A[N]){
cout<<A.substr(0,N)<<endl;
return 0;
}
}
}
cout<<-1<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:46:23: error: 'class std::vector<char>' has no member named 'substr'
46 | cout<<A.substr(0,N)<<endl;
| ^~~~~~
|
s892327817 | p03798 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;
int main()
{
ll n;
string s;
cin >> n >> s;
vector<char> t(n);
//SSから始まる可能性
t[0] = 'S';
t[1] = 'S';
for (int i = 2; i < n; i++)
{
if (s[i - 1] == 'o')
{
if (t[i - 1] == 'S')
t[i] = t[i - 2];
else if (t[i - 2] == 'S')
t[i] = 'W';
else
t[i] = 'S';
}
else
{
if (t[i - 1] == 'S')
{
if (t[i - 2] == 'S')
t[i] = 'W';
else
t[i] = 'S';
}
else
{
t[i] = t[i - 2];
}
}
}
//答え合わせ
char ans;
if (s[0] == 'o')
ans = 'S';
else
ans = 'W';
if (ans = t[n - 1])
{
rep(i, n) cout << t[i];
cout << endl;
return 0;
}
//SWから始まる可能性
t[0] = 'S';
t[1] = 'W';
for (int i = 2; i < n; i++)
{
if (s[i - 1] == 'o')
{
if (t[i - 1] == 'S')
t[i] = t[i - 2];
else if (t[i - 2] == 'S')
t[i] = 'W';
else
t[i] = 'S';
}
else
{
if (t[i - 1] == 'S')
{
if (t[i - 2] == 'S')
t[i] = 'W';
else
t[i] = 'S';
}
else
{
t[i] = t[i - 2];
}
}
}
//答え合わせ
char ans;
if (s[0] == 'o')
ans = 'W';
else
ans = 'S';
if (ans = t[n - 1])
{
rep(i, n) cout << t[i];
cout << endl;
return 0;
}
//WSから始まる可能性
t[0] = 'W';
t[1] = 'S';
for (int i = 2; i < n; i++)
{
if (s[i - 1] == 'o')
{
if (t[i - 1] == 'S')
t[i] = t[i - 2];
else if (t[i - 2] == 'S')
t[i] = 'W';
else
t[i] = 'S';
}
else
{
if (t[i - 1] == 'S')
{
if (t[i - 2] == 'S')
t[i] = 'W';
else
t[i] = 'S';
}
else
{
t[i] = t[i - 2];
}
}
}
//答え合わせ
char ans;
if (s[0] == 'o')
ans = 'W';
else
ans = 'S';
if (ans = t[n - 1])
{
rep(i, n) cout << t[i];
cout << endl;
return 0;
}
//SSから始まる可能性
t[0] = 'S';
t[1] = 'S';
for (int i = 2; i < n; i++)
{
if (s[i - 1] == 'o')
{
if (t[i - 1] == 'S')
t[i] = t[i - 2];
else if (t[i - 2] == 'S')
t[i] = 'W';
else
t[i] = 'S';
}
else
{
if (t[i - 1] == 'S')
{
if (t[i - 2] == 'S')
t[i] = 'W';
else
t[i] = 'S';
}
else
{
t[i] = t[i - 2];
}
}
}
//答え合わせ
char ans;
if (s[0] == 'o')
ans = 'W';
else
ans = 'S';
if (ans = t[n - 1])
{
rep(i, n) cout << t[i];
cout << endl;
return 0;
}
cout << -1 << endl;
}
//方針ok
//実装力 | a.cc: In function 'int main()':
a.cc:89:10: error: redeclaration of 'char ans'
89 | char ans;
| ^~~
a.cc:47:10: note: 'char ans' previously declared here
47 | char ans;
| ^~~
a.cc:131:10: error: redeclaration of 'char ans'
131 | char ans;
| ^~~
a.cc:47:10: note: 'char ans' previously declared here
47 | char ans;
| ^~~
a.cc:173:10: error: redeclaration of 'char ans'
173 | char ans;
| ^~~
a.cc:47:10: note: 'char ans' previously declared here
47 | char ans;
| ^~~
|
s492542800 | p03798 | C++ | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};
using mint = Fp<MOD>;
vector<bool> seen,finished;
int pos = -1;
int ca=0;
int f=0;
void dfs(const Graph &G, int v, int p) {
seen[v] = true;
for (auto nv : G[v]) {
if (nv == p) continue;
if (finished[nv]) continue;
if (seen[nv] && !finished[nv]) {
pos = nv;f++;
return;
}
dfs(G, nv, v);
// サイクル検出したならば真っ直ぐに抜けていく
if (pos != -1) {
return;}}
finished[v] = true;
}
mint calc(long long N, long long K) {
mint res = 1;
for (long long n = 0; n < K; ++n) {
res *= (N - n);
res /= (n + 1);
}
return res;
}
struct UnionFind {
vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2
UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
for(ll i = 0; i < N; i++) par[i] = i;
}
ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根}
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(ll x, ll y) { // xとyの木を併合
ll rx = root(x); //xの根をrx
ll ry = root(y); //yの根をry
if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける
}
bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
ll rx = root(x);
ll ry = root(y);
return rx == ry;
}
};
int main() {
else cout << -1 << endl;
} | a.cc: In function 'int main()':
a.cc:135:2: error: 'else' without a previous 'if'
135 | else cout << -1 << endl;
| ^~~~
|
s029784581 | p03798 | C++ | #include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
bool check(vb &animal, string s){
int n = s.size();
REP(i,1,n-1){
if(animal.at(i)){
if(s.at(i) == 'o') animal.at(i+1) = animal.at(i-1);
else animal.at(i+1) = (!animal.at(i-1));
}else{
if(s.at(i) == 'o') animal.at(i+1) = (!animal.at(i-1));
else animal.at(i+1) = animal.at(i-1);
}
//cout << animal.at(i) << " " << s.at(i) << " " << animal.at(i-1) << " " << animal.at(i+1) << endl;
}
if(animal.at(n-1)){
if(s.at(n-1) == 'o') return animal.at(0) == animal.at(n-2);
else return animal.at(0) != animal.at(n-2);
}else{
if(s.at(n-1) == 'o') return animal.at(0) != animal.at(n-2);
else return animal.at(0) == animal.at(n-2);
}
} | /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s704212523 | p03798 | C++ | #include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)
#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))
using namespace std;
typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;
template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
return in >> pr.first >> pr.second;
}
// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
};
char guess(char ans, char before, char animal)
{
char other = before == 'S' ? 'W' : 'S';
if (animal == 'S') {
return ans == 'o' ? before : other;
} else {
return ans == 'x' ? before : other;
}
};
bool check(int i, string& Answer, const string& S)
{
char now = guess(S[i - 1], Answer[i - 2], Answer[i - 1]);
if (i == S.size()) {
if (now != Answer[0])
return false;
now = guess(S[0], Answer.back(), answer[0]);
return now == Answer[1];
}
Answer[i] = now;
return check(i + 1, Answer, S);
};
int main(int argc, char **argv)
{
io_init();
// Actual program code starts here.
int N;
string S;
cin >> N >> S;
string Answer(N, '_');
for (char c1 : "SW")
for (char c2 : "SW") {
Answer[0] = c1;
Answer[1] = c2;
if (check(2, Answer, S)) {
cout << Answer << endl;
return 0;
}
}
cout << -1 << endl;
return 0;
}; | a.cc: In function 'bool check(int, std::string&, const std::string&)':
a.cc:69:42: error: 'answer' was not declared in this scope; did you mean 'Answer'?
69 | now = guess(S[0], Answer.back(), answer[0]);
| ^~~~~~
| Answer
|
s488551849 | p03798 | C++ | #include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define S 0
#define W 1
signed main(){
lli n;
cin>>n;
string s;
cin>>s;
REP(start,0,2)REP(side,0,2){
lli ans[100100];
REP(i,0,100100)ans[i]=-1;
ans[0]=start;
ans[1]=side;
ans[n+2] = (ans[0]+ans[1]+(s.at(i)!='o'))%2;
REP(i,1,n){
ans[i+1] = (ans[i-1]+ans[i]+(s.at(i)!='o'))%2;
}
if(ans[0]==ans[n] && ans[n-1] == ans[n+2]){
REP(i,0,n){
if(ans[i]==0)cout<<"S";
else cout<<"W";
}
cout<<endl;
return 0;
}
}
cout<<-1<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:31:49: error: 'i' was not declared in this scope
31 | ans[n+2] = (ans[0]+ans[1]+(s.at(i)!='o'))%2;
| ^
|
s812050486 | p03798 | C++ | #include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const int MAX_C = 2010;
long long Com[MAX_C][MAX_C] = {0};
int main(){
int N; string S; cin >> N >> S;
int ans[N][4];
if(S[0]=='o'){
ans[0][0]=0; ans[1][0]=0; ans[N-1][0]=0;
ans[0][1]=0; ans[1][1]=1; ans[N-1][1]=1;
ans[0][2]=1; ans[1][2]=1; ans[N-1][2]=0;
ans[0][3]=1; ans[1][3]=0; ans[N-1][3]=1;
}
else{
ans[0][0]=0; ans[1][0]=1; ans[N-1][0]=0;
ans[0][1]=0; ans[1][1]=0; ans[N-1][1]=1;
ans[0][2]=1; ans[1][2]=1; ans[N-1][2]=1;
ans[0][3]=1; ans[1][3]=0; ans[N-1][3]=0;
}
rep(i, 4){
ans[N][i] = ans[0][i];
}
bool check[4];
rep(i, 4)check[i]=true;
for(int i=1; i<N; i++){
if(S[i]=='o'){
rep(j, 4){
if(i==N-2 || i==N-1){
if(ans[i][j] && ans[i-1][j]==ans[i+1][j]) check[j]=false;
if(!(ans[i][j]) && ans[i-1][j]!=ans[i+1][j]) check[j]=false;
}
if(ans[i][j]) ans[i+1][j]=1-ans[i-1][j];
else ans[i+1][j]=ans[i-1][j];
}
}
else{
rep(j, 4){
if(i==N-2 || i==N-1){
if(ans[i][j] && ans[i-1][j]!=ans[i+1][j]) check[j]=false;
if(!(ans[i][j]) && ans[i-1][j]==ans[i+1][j]) check[j]=false;
}
if(ans[i][j]) ans[i+1][j]=ans[i-1][j];
else ans[i+1][j]=1-ans[i-1][j];
}
}
}
rep(i, 4){
if(check[i]){
rep(j, N){
if(ans[j][i]) cout << 'W'; else cout << 'S';
}
cout << endl; return 0;
}
}
cout << -1 << endl; | a.cc: In function 'int main()':
a.cc:78:22: error: expected '}' at end of input
78 | cout << -1 << endl;
| ^
a.cc:28:11: note: to match this '{'
28 | int main(){
| ^
|
s450437645 | p03798 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N;
string s;
cin>>N>>s;
vector<int> animal={1,-1};
vector<int> ss(N);
bool flag=false;
for(int i=0;i<2;i++){
for(int j=0;j<2;j++){
int ss.at(0)=animal.at(i);
int ss.at(1)=animal.at(j);
for(int k=1;k<N-1;k++){
int x;
if(s.at(k)=='o'){
x=1;
}else{
x=-1;
}
ss.at(k+1)=x*ss.at(k-1);
}
if(ss.at(N-1)*ss.at(0)==ss.at(1)){
flag=true;
break;
}
}
}
if(flag){
for(int i=0;i<N;i++){
if(ss.at(i)==1){
cout<<'S';
}else{
cout<<'W';
}
cout<<endl;
}
}else{
cout<<-1<<endl;
}
}
| a.cc: In function 'int main()':
a.cc:13:13: error: expected initializer before '.' token
13 | int ss.at(0)=animal.at(i);
| ^
a.cc:14:13: error: expected initializer before '.' token
14 | int ss.at(1)=animal.at(j);
| ^
|
s314535877 | p03798 | C++ | #include<bits/stdc++.h>
using namespace std;
vecetor<bool> solve(int n, vector<bool> &s)
{
for(int i = 0; i < 2; i++)
{
for(int j = 0; j < 2; j++)
{
vector<bool> res(n);
res[0] = i;
res[1] = j;
for(int k = 2; k < n; k++)
res[k] = (res[k - 2] ^ res[k - 1] ^ s[k - 1]);
if (s[n - 1] == (res[n - 2] ^ res[n - 1] ^ res[0]) &&
s[0] == (res[n - 1] ^ res[0] ^ res[1]))
return res;
}
}
return vector<bool>();
}
int main()
{
int n;
cin>>n;
vector<bool> v(n);
for(int i = 0; i < n; i++)
{
char c;
cin>>c;
v[i] = (c == 'o');
}
vector<bool> res = solve(n, v);
if(res.empty())
cout <<-1<<"\n";
else
{
for (bool p : res)
cout << (p ? 'S' : 'W');
cout << "\n";
}
return 0;
}
| a.cc:4:1: error: 'vecetor' does not name a type
4 | vecetor<bool> solve(int n, vector<bool> &s)
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:34:28: error: 'solve' was not declared in this scope
34 | vector<bool> res = solve(n, v);
| ^~~~~
|
s515450952 | p03798 | C++ | #include<bits/stdc++.h>
using namespace std;
vecetor<bool>(int n, vector<bool> &s)
{
for(int i = 0; i < 2; i++)
{
for(int j = 0; j < 2; j++)
{
vector<bool> res(n);
res[0] = i;
res[1] = j;
for(int k = 2; k < n; k++)
res[k] = (res[k - 2] ^ res[k - 1] ^ s[k - 1]);
if (s[n - 1] == (res[n - 2] ^ res[n - 1] ^ res[0]) &&
s[0] == (res[n - 1] ^ res[0] ^ res[1]))
return res;
}
}
return vector<bool>();
}
int main()
{
int n;
cin>>n;
vector<bool> v(n);
for(int i = 0; i < n; i++)
{
char c;
cin>>c;
v[i] = (c == 'o');
}
vector<bool> res = solve(n, v);
if(res.empty())
cout <<-1<<"\n";
else
{
for (bool p : res)
cout << (p ? 'S' : 'W');
cout << "\n";
}
return 0;
} | a.cc:4:1: error: 'vecetor' does not name a type
4 | vecetor<bool>(int n, vector<bool> &s)
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:34:28: error: 'solve' was not declared in this scope
34 | vector<bool> res = solve(n, v);
| ^~~~~
|
s641451320 | p03798 | Java | mport java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String input = sc.next();
char[] result = new char[n];
Arrays.fill(result, 'S');
if (input.charAt(0) == 'o')
result[1] = 'S';
else
result[1] = 'W';
for (int i = 1; i < n; i++) {
if (result[i] == 'S') {
if (input.charAt(i) == 'o') {
if (result[i - 1] == 'S')
result[(i + 1) % n] = 'S';
else
result[(i + 1) % n] = 'W';
} else {
if (result[i - 1] == 'S')
result[(i + 1) % n] = 'W';
else
result[(i + 1) % n] = 'S';
}
} else {
if (input.charAt(i) == 'o') {
if (result[i - 1] == 'S')
result[(i + 1) % n] = 'W';
else
result[(i + 1) % n] = 'S';
} else {
if (result[i - 1] == 'S')
result[(i + 1) % n] = 'S';
else
result[(i + 1) % n] = 'W';
}
}
}
if (result[0] != 'S' && result[n - 1] != 'S') {
Arrays.fill(result, 'S');
if (input.charAt(0) == 'o')
result[1] = 'W';
else
result[1] = 'S';
for (int i = 1; i < n; i++) {
if (result[i] == 'S') {
if (input.charAt(i) == 'o') {
if (result[i - 1] == 'S')
result[(i + 1) % n] = 'S';
else
result[(i + 1) % n] = 'W';
} else {
if (result[i - 1] == 'S')
result[(i + 1) % n] = 'W';
else
result[(i + 1) % n] = 'S';
}
} else {
if (input.charAt(i) == 'o') {
if (result[i - 1] == 'S')
result[(i + 1) % n] = 'W';
else
result[(i + 1) % n] = 'S';
} else {
if (result[i - 1] == 'S')
result[(i + 1) % n] = 'S';
else
result[(i + 1) % n] = 'W';
}
}
}
if(result[0] != 'S' && result[n - 1] == 'W')
System.out.println(-1);
else{
StringBuilder res = new StringBuilder();
res.append(result);
System.out.println(res.toString());
}
} else {
StringBuilder res = new StringBuilder();
res.append(result);
System.out.println(res.toString());
}
}
}
| Main.java:1: error: class, interface, enum, or record expected
mport java.util.Arrays;
^
Main.java:2: error: class, interface, enum, or record expected
import java.util.Scanner;
^
2 errors
|
s143611517 | p03798 | C++ | #include <bits/stdc++.h>
using namespace std;
char p[101000];
int S[101000],P[101000],n;
int main()
{
scanf ("%d",&n);
scanf ("%S",p);
int i,j;
for(i=0;p[i];i++)
{
if(p[i]=='o')P[i+1]=0;
else P[i+1]=1;
}
P[n+1]=P[1];
for(i=0;i<8;i++)
{
S[0]=i&1;
S[1]=(i>>1)&1;
S[2]=(i>>2)&1;
for(j=2;j<=n+1;j++)
{
S[j+1]=S[j-2]^P[j];
}
if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^[2]^S[n+2])continue;
for(j=1;j<=n;j++)
{
print("c",(S[j]^S[j-1])?'W':'S');
}
return 0;
}
print ("-1\n");
return 0;
}
| a.cc: In function 'int main()':
a.cc:25:48: error: expected identifier before numeric constant
25 | if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^[2]^S[n+2])continue;
| ^
a.cc: In lambda function:
a.cc:25:50: error: expected '{' before '^' token
25 | if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^[2]^S[n+2])continue;
| ^
a.cc: In function 'int main()':
a.cc:25:46: error: no match for 'operator^' (operand types are 'int' and 'main()::<lambda()>')
25 | if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^[2]^S[n+2])continue;
| ~~~~~~~~~~~^~~~
| | |
| int main()::<lambda()>
In file included from /usr/include/c++/14/streambuf:43,
from /usr/include/c++/14/bits/streambuf_iterator.h:35,
from /usr/include/c++/14/iterator:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54,
from a.cc:1:
/usr/include/c++/14/bits/ios_base.h:94:3: note: candidate: 'constexpr std::_Ios_Fmtflags std::operator^(_Ios_Fmtflags, _Ios_Fmtflags)'
94 | operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:94:46: note: no known conversion for argument 2 from 'main()::<lambda()>' to 'std::_Ios_Fmtflags'
94 | operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:144:3: note: candidate: 'constexpr std::_Ios_Openmode std::operator^(_Ios_Openmode, _Ios_Openmode)'
144 | operator^(_Ios_Openmode __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:144:46: note: no known conversion for argument 2 from 'main()::<lambda()>' to 'std::_Ios_Openmode'
144 | operator^(_Ios_Openmode __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:191:3: note: candidate: 'constexpr std::_Ios_Iostate std::operator^(_Ios_Iostate, _Ios_Iostate)'
191 | operator^(_Ios_Iostate __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:191:44: note: no known conversion for argument 2 from 'main()::<lambda()>' to 'std::_Ios_Iostate'
191 | operator^(_Ios_Iostate __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bitset:1577:5: note: candidate: 'template<long unsigned int _Nb> std::bitset<_Nb> std::operator^(const bitset<_Nb>&, const bitset<_Nb>&)'
1577 | operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/bitset:1577:5: note: template argument deduction/substitution failed:
a.cc:25:50: note: mismatched types 'const std::bitset<_Nb>' and 'int'
25 | if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^[2]^S[n+2])continue;
| ^
In file included from /usr/include/c++/14/valarray:605,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/bits/valarray_after.h:410:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__bitwise_xor, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__bitwise_xor, typename _Dom1::value_type>::result_type> std::operator^(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
410 | _DEFINE_EXPR_BINARY_OPERATOR(^, struct std::__bitwise_xor)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:410:5: note: template argument deduction/substitution failed:
a.cc:25:50: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
25 | if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^[2]^S[n+2])continue;
| ^
/usr/include/c++/14/bits/valarray_after.h:410:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_xor, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__bitwise_xor, typename _Dom1::value_type>::result_type> std::operator^(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
410 | _DEFINE_EXPR_BINARY_OPERATOR(^, struct std::__bitwise_xor)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:410:5: note: template argument deduction/substitution failed:
a.cc:25:50: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
25 | if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^[2]^S[n+2])continue;
| ^
/usr/include/c++/14/bits/valarray_after.h:410:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_xor, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__bitwise_xor, typename _Dom1::value_type>::result_type> std::operator^(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
410 | _DEFINE_EXPR_BINARY_OPERATOR(^, struct std::__bitwise_xor)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:410:5: note: template argument deduction/substitution failed:
a.cc:25:50: note: 'main()::<lambda()>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
25 | if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^[2]^S[n+2])continue;
| ^
/usr/include/c++/14/bits/valarray_after.h:410:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_xor, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__bitwise_xor, typename _Dom1::value_type>::result_type> std::operator^(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)'
410 | _DEFINE_EXPR_BINARY_OPERATOR(^, struct std::__bitwise_xor)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:410:5: note: template argument deduction/substitution failed:
a.cc:25:50: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
25 | if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^[2]^S[n+2])continue;
| ^
/usr/include/c++/14/bits/valarray_after.h:410:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_xor, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__bitwise_xor, typename _Dom1::value_type>::result_type> std::operator^(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
410 | _DEFINE_EXPR_BINARY_OPERATOR(^, struct std::__bitwise_xor)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:410:5: note: template argument deduction/substitution failed:
a.cc:25:50: note: 'main()::<lambda()>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
25 | if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^[2]^S[n+2])continue;
| ^
/usr/include/c++/14/valarray:1201:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__bitwise_xor, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__bitwise_xor, _Tp>::result_type> std::operator^(const valarray<_Tp>&, const valarray<_Tp>&)'
1201 | _DEFINE_BINARY_OPERATOR(^, __bitwise_xor)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1201:1: note: template argument deduction/substitution failed:
a.cc:25:50: note: mismatched types 'const std::valarray<_Tp>' and 'int'
25 | if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^[2]^S[n+2])continue;
| ^
/usr/include/c++/14/valarray:1201:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__bitwise_xor, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__bitwise_xor, _Tp>::result_type> std::operator^(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)'
1201 | _DEFINE_BINARY_OPERATOR(^, __bitwise_xor)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1201:1: note: template argument deduction/substitution failed:
a.cc:25:50: note: mismatched types 'const std::valarray<_Tp>' and 'int'
25 | if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^[2]^S[n+2])continue;
| ^
/usr/include/c++/14/valarray:1201:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__bitwise_xor, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__bitwise_xor, _Tp>::result_type> std::operator^(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)'
1201 | _DEFINE_BINARY_OPERATOR(^, __bitwise_xor)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1201:1: note: template argument deduction/substitution failed:
a.cc:25:50: note: 'main()::<lambda()>' is not derived from 'const std::valarray<_Tp>'
25 | if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^[2]^S[n+2])continue;
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/include/c++/14/cstddef:146:3: note: candidate: 'constexpr std::byte std::operator^(byte, byte)'
146 | operator^(byte __l, byte __r) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:146:18: note: no known conversion for argument 1 from 'int' to 'std::byte'
146 | operator^(byte __l, byte __r) noexcept
| ~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:176:
/usr/include/c++/14/futur |
s612960006 | p03798 | C++ | #include <bits/stdc++.h>
using namespace std;
int main()
{
const int M=le6;
int a[M];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifdef LOCAL
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
int n;
string s;
cin>>n>>s;
s=s+s;
for(int i1=0;i1<2;i1++)
{
for(int i2=0;i2<2;i2++)
{
a[0]=i1;
a[1]=i2;
for(int i=2;i<=n+1;i++)
{
if(s[i-1]=='o'&&a[i-1]==0)a[i]=1-a[i-2];
if(s[i-1]=='o'&&a[i-1]==1)a[i]=a[i-2];
if(s[i-1]=='x'&&a[i-1]==0)a[i]=a[i-2];
if(s[i-1]=='x'&&a[i-1]==1)a[i]=1-a[i-2];
}
if(a[n]==a[0]&&a[n+1]==a[1]){
for(int i=0;i<n;i++)
{
cout<<(a[i]?"S":"W");
}
return 0;
}
}
}
}
cout<<-1;
return 0;
} | a.cc: In function 'int main()':
a.cc:5:13: error: 'le6' was not declared in this scope
5 | const int M=le6;
| ^~~
a.cc:6:7: error: size of array 'a' is not an integral constant-expression
6 | int a[M];
| ^
a.cc:7:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
7 | int main()
| ^~
a.cc:7:9: note: remove parentheses to default-initialize a variable
7 | int main()
| ^~
| --
a.cc:7:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:8:1: error: a function-definition is not allowed here before '{' token
8 | {
| ^
|
s994131360 | p03798 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
long long n,m,i,j,f[100010],yc[100010];
bool g;
cin>>n;
char x;
for(i=1;i<=n;i++){
cin>>x;
if(x=='o')f[i]=1;
else f[i]=0;
}
yc[1]=1;yc[2]=1;
g=0;
for(i=3;i<=n;i++){
if(yc[i-1]==1){
if(f[i-1]==1)
yc[i]=yc[i-2];
else{
if(yc[i-2]==1)yc[i]=0;
else yc[i]=1;
}
}
else{
if(f[i-1]==1){
if(yc[i-2]==1)yc[i]=0;
else yc[i]=1;
}
else
yc[i]=yc[i-2];
}
}
if(yc[1]==1){
if(f[1]==1){
if(yc[n]==1){
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
else{
if(yc[n]==1){
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
}
else{
if(f[1]==1){
if(yc[n]==1){
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
else{
if(yc[n]==1){
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
}
if(gx==0){
for(i=1;i<=n;i++){
if(yc[i]==1)cout<<'S';
else cout<<'W';
}
return 0;
}
yc[1]=1;yc[2]=0;
g=0;
for(i=3;i<=n;i++){
if(yc[i-1]==1){
if(f[i-1]==1)
yc[i]=yc[i-2];
else{
if(yc[i-2]==1)yc[i]=0;
else yc[i]=1;
}
}
else{
if(f[i-1]==1){
if(yc[i-2]==1)yc[i]=0;
else yc[i]=1;
}
else
yc[i]=yc[i-2];
}
}
if(yc[1]==1){
if(f[1]==1){
if(yc[n]==1){
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
else{
if(yc[n]==1){
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
}
else{
if(f[1]==1){
if(yc[n]==1){
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
else{
if(yc[n]==1){
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
}
if(g==0){
for(i=1;i<=n;i++){
if(yc[i]==1)cout<<'S';
else cout<<'W';
}
return 0;
}
yc[1]=0;yc[2]=1;
g=0;
for(i=3;i<=n;i++){
if(yc[i-1]==1){
if(f[i-1]==1)
yc[i]=yc[i-2];
else{
if(yc[i-2]==1)yc[i]=0;
else yc[i]=1;
}
}
else{
if(f[i-1]==1){
if(yc[i-2]==1)yc[i]=0;
else yc[i]=1;
}
else
yc[i]=yc[i-2];
}
}
if(yc[1]==1){
if(f[1]==1){
if(yc[n]==1){
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
else{
if(yc[n]==1){
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
}
else{
if(f[1]==1){
if(yc[n]==1){
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
else{
if(yc[n]==1){
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
}
if(g==0){
for(i=1;i<=n;i++){
if(yc[i]==1)cout<<'S';
else cout<<'W';
}
return 0;
}
yc[1]=0;yc[2]=0;
g=0;
for(i=3;i<=n;i++){
if(yc[i-1]==1){
if(f[i-1]==1)
yc[i]=yc[i-2];
else{
if(yc[i-2]==1)yc[i]=0;
else yc[i]=1;
}
}
else{
if(f[i-1]==1){
if(yc[i-2]==1)yc[i]=0;
else yc[i]=1;
}
else
yc[i]=yc[i-2];
}
}
if(yc[1]==1){
if(f[1]==1){
if(yc[n]==1){
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
else{
if(yc[n]==1){
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
}
else{
if(f[1]==1){
if(yc[n]==1){
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]==yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]==yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
else{
if(yc[n]==1){
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
}
else{
if(f[n]==1){
if(yc[2]!=yc[n]||yc[n-1]==yc[1])g=1;
}
else{
if(yc[2]!=yc[n]||yc[n-1]!=yc[1])g=1;
}
}
}
}
if(g==0){
for(i=1;i<=n;i++){
if(yc[i]==1)cout<<'S';
else cout<<'W';
}
return 0;
}
cout<<-1;
return 0;
} | a.cc: In function 'int main()':
a.cc:109:12: error: 'gx' was not declared in this scope; did you mean 'x'?
109 | if(gx==0){
| ^~
| x
|
s615264038 | p03798 | C++ | // luogu-judger-enable-o2
#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
int f=1,x=0;char ch;
do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
A ans=1;
for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
return ans;
}
struct FastIO{
static const int S=1310720;
int wpos;char wbuf[S];
FastIO():wpos(0){}
inline int xchar(){
static char buf[S];
static int len=0,pos=0;
if(pos==len)pos=0,len=fread(buf,1,S,stdin);
if(pos==len)return -1;
return buf[pos++];
}
inline int read(){
int c=xchar(),x=0;
while(c<=32&&~c)c=xchar();
if(c==-1)return -1;
for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
return x;
}
}io;
//#define read io.read
int main()
{
int n;
string str;
cin >> n >> str;
for(int i=0;i<4;i++)
{
wlf[0]=i&1;
wlf[1]=(i>>1)&1;
for(int j=2;j<n;j++)
{
wlf[j]=wlf[j-1]^wlf[j-2]^(str[j-1]=='x');
}
bool flg=true;
for(int i=0;i<n;i++)
{
int le=(i-1+n)%n;
int ri=(i+1+n)%n;
if(wlf[ri]!=wlf[i]^wlf[le]^(str[i]=='x'))
{
flg=false;
break;
}
}
if(flg)
{
for(int i=0;i<n;i++)
{
if(wlf[i]) cout << 'W';
else cout << 'S';
}
cout << endl;
return 0;
}
}
cout << "-1";
return 0;
}
| a.cc: In function 'int main()':
a.cc:62:17: error: 'wlf' was not declared in this scope
62 | wlf[0]=i&1;
| ^~~
|
s389115595 | p03798 | C++ | #define _CRT_SECURE_NO_WARNINGS
#define MATH_PI 3.14159265358979323846264338327950288419716939
#define DIVIDER9 1000000007
#define lli long long int
#include <iostream>
#include <string.h>
#include <fstream>
#include <math.h>
using namespace std;
#ifdef _WIN32
#pragma warning(disable : 4101)
signed wait(){
char wait_dummy[256];
scanf("%c", &wait_dummy);
return 0;
}
template <typename ... Args>
void dout(const char *format, Args const & ... args){
printf(format, args ...);
}
#define MAX_CHARBUF 65536
#define DATAFILE "data.dat"
class csLocalInput{
int FileOpen();
public:
FILE *fp;
csLocalInput();
};
csLocalInput::csLocalInput() {
FileOpen();
}
int csLocalInput::FileOpen() {
fp = fopen(DATAFILE, "rt");
return 1;
}
csLocalInput local_in;
#define DEBUG 1
#else
inline signed wait() { return 0; }
inline void dout(const char *arg, ...) {}
#endif
template<typename T>inline void SWAP(T &a, T &b) { T t = a; a = b; b = t; }
inline void CSWAP(char *&a, char *&b) { char *t = a; a = b; b = t; }
#define CLIP(ptr, min, max) {if((min)<=(max)){if(ptr<(min)){ptr=(min);}if(ptr>(max)){ptr=(max);}}}
#define Sin(deg) sin((deg)*MATH_PI/180.0)
#define Cos(deg) cos((deg)*MATH_PI/180.0)
#define Tan(deg) tan((deg)*MATH_PI/180.0)
#define Rad(deg) ((deg)*MATH_PI/180.0)
#define rep(param, num) for(int param=0 ; param<num ; ++param)
#define fi(num) for(int i=0 ; i<num ; ++i)
#define fj(num) for(int j=0 ; j<num ; ++j)
#define fk(num) for(int k=0 ; k<num ; ++k)
#define fl(num) for(int l=0 ; l<num ; ++l)
#define fn(num) for(int n=0 ; n<num ; ++n)
#define ffr(param, num) for(int param=num-1 ; param>=0 ; --param)
#define fir(num) for(int i=num-1 ; i>=0 ; --i)
#define fjr(num) for(int j=num-1 ; j>=0 ; --j)
#define fkr(num) for(int k=num-1 ; k>=0 ; --k)
#define flr(num) for(int l=num-1 ; l>=0 ; --l)
#define fnr(num) for(int n=num-1 ; n>=0 ; --n)
#define gi(p) int p; Gi(p)
#define gi2(p1, p2) int p1, p2; Gi2(p1, p2)
#define gi3(p1, p2, p3) int p1, p2, p3; Gi3(p1, p2, p3)
#define gi4(p1, p2, p3, p4) int p1, p2, p3, p4; Gi4(p1, p2, p3, p4)
#define glli(p) lli p; Glli(p)
#define glli2(p1, p2) lli p1, p2; Glli2(p1, p2)
#define glli3(p1, p2, p3) lli p1, p2, p3; Glli3(p1, p2, p3)
#define glli4(p1, p2, p3, p4) lli p1, p2, p3, p4; Glli4(p1, p2, p3, p4)
#define gf(p) double p; Gf(p);
#define gf2(p1, p2) double p1, p2; Gf2(p1, p2);
#define gf3(p1, p2, p3) double p1, p2, p3; Gf3(p1, p2, p3);
#define gf4(p1, p2, p3, p4) double p1, p2, p3, p4; Gf4(p1, p2, p3, p4);
#define Gi(p) Scanf("%d", p)
#define Gi2(p1, p2) Scanf2("%d %d", p1, p2)
#define Gi3(p1, p2, p3) Scanf3("%d %d %d", p1, p2, p3)
#define Gi4(p1, p2, p3, p4) Scanf4("%d %d %d %d", p1, p2, p3, p4)
#define Glli(p) Scanf("%lld", p)
#define Glli2(p1, p2) Scanf2("%lld %lld", p1, p2)
#define Glli3(p1, p2, p3) Scanf3("%lld %lld %lld", p1, p2, p3)
#define Glli4(p1, p2, p3, p4) Scanf4("%lld %lld %lld %lld", p1, p2, p3, p4)
#define Gf(p) Scanf("%f", p)
#define Gf2(p1, p2) Scanf2("%f %f", p1, p2)
#define Gf3(p1, p2, p3) Scanf3("%f %f %f", p1, p2, p3)
#define Gf4(p1, p2, p3, p4) Scanf4("%f %f %f %f", p1, p2, p3, p4)
#ifdef DEBUG
#define GC(buf) fscanf(local_in.fp, "%s", buf)
#define Scanf(expr, p) fscanf(local_in.fp, expr, &p)
#define Scanf2(expr, p1, p2) fscanf(local_in.fp, expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) fscanf(local_in.fp, expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) fscanf(local_in.fp, expr, &p1, &p2, &p3, &p4)
#else
#define gc(buf) Scanf("%s", buf)
#define Scanf(expr, p) scanf(expr, &p)
#define Scanf2(expr, p1, p2) scanf(expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) scanf(expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) scanf(expr, &p1, &p2, &p3, &p4)
#endif
#define ans(p) cout << p << endl;
#define ans_end(p) cout << p << endl; return wait();
void CombSort(int N, int *ar, int order_ascending = 1) { int h = int(N / 1.3); int flag; int i; while (true) { flag = 0; for (i = 0; i + h < N; ++i) { if ((order_ascending&&ar[i] > ar[i + h]) || (!order_ascending&&ar[i] < ar[i + h])) { swap<int>(ar[i], ar[i + h]); flag = 1; } }if (h == 1 && !flag)break; if (h == 9 || h == 10) h = 11; if (h > 1)h = int(h / 1.3); } }
void CombSort(int N, lli *ar, int order_ascending = 1) { int h = int(N / 1.3); int flag; int i; while (true) { flag = 0; for (i = 0; i + h < N; ++i) { if ((order_ascending&&ar[i] > ar[i + h]) || (!order_ascending&&ar[i] < ar[i + h])) { swap<lli>(ar[i], ar[i + h]); flag = 1; } }if (h == 1 && !flag)break; if (h == 9 || h == 10) h = 11; if (h > 1)h = int(h / 1.3); } }
int EuclideanAlgorithm(int N, int *ar){
fn(N - 1){
while (true){
if (ar[n] % ar[n + 1] == 0 || ar[n + 1] % ar[n] == 0) {
ar[n + 1] = ar[n] < ar[n + 1] ? ar[n] : ar[n + 1];
break;
}
if (ar[n] > ar[n + 1]) {
ar[n] %= ar[n + 1];
}
else {
ar[n + 1] %= ar[n];
}
}
}
return ar[N - 1];
}
template<typename T>void CombSort(int N, T *ar, int order_ascending = 1) {
int i, flag;
int h = int(N / 1.3);
while (true) {
flag = 0;
for (i = 0; i + h < N; ++i) {
if (
order_ascending && ar[i].SortValue > ar[i + h].SortValue ||
!order_ascending && ar[i].SortValue < ar[i + h].SortValue
) {
swap<T>(ar[i], ar[i + h]);
flag = 1;
}
}
if (h > 1) {
h = int(h / 1.3);
if (h == 9 || h == 10) h = 11;
}
else {
if (!flag) break;
}
}
}
#include <vector>
#include <algorithm>
struct UnionFind {
vector<int> par;
UnionFind(int N) : par(N) {
for (int i = 0; i < N; i++) par[i] = i;
}
int root(int x) {
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(int x, int y) {
int rx = root(x);
int ry = root(y);
if (rx == ry) return;
par[rx] = ry;
}
bool same(int x, int y) {
int rx = root(x);
int ry = root(y);
return rx == ry;
}
};
void Replace(char *c, int len, char before, char after) {
fi(len){
if(c[i] == before) c[i] = after;
}
}
void Replace(char *c, char before, char after){
int len = strlen(c);
Replace(c, len, before, after);
}
class csNode{
public:
csNode(){
}
};
class csStack{
public:
csStack(){
num = 0;
}
void alloc(int size){
param = new int[size];
}
void sort(int order = 1){
if(num > 1) CombSort(num, param, order);
}
int num;
int *param;
void push(int p){
param[num++] = p;
}
};
char s[200010];
char ret[100010];
int a[100010];
signed main() {
gi(n);
GC(s);
fk(4){
a[0] = k % 2;
a[1] = k / 2;
ret[0] = a[0];
ret[1] = a[1];
for(int i=0 ; i<n-2 ; ++i){
if (a[i + 1] == 0 && s[i + 1] == 'o') a[i + 2] = a[i];
if (a[i + 1] == 0 && s[i + 1] == 'x') a[i + 2] = 1 - a[i];
if (a[i + 1] == 1 && s[i + 1] == 'o') a[i + 2] = 1 - a[i];
if (a[i + 1] == 1 && s[i + 1] == 'x') a[i + 2] = a[i];
ret[i + 2] = a[i + 2];
}
if(
(
a[n - 1] == 0 && s[n - 1] == 'o' && a[0] == a[n - 2] ||
a[n - 1] == 0 && s[n - 1] == 'x' && a[0] == 1 - a[n - 2] ||
a[n - 1] == 1 && s[n - 1] == 'o' && a[0] == 1 - a[n - 2] ||
a[n - 1] == 1 && s[n - 1] == 'x' && a[0] == a[n - 2]
) && (
a[0] == 0 && s[0] == 'o' && a[1] == a[n - 1] ||
a[0] == 0 && s[0] == 'x' && a[1] == 1 - a[n - 1] ||
a[0] == 1 && s[0] == 'o' && a[1] == 1 - a[n - 1] ||
a[0] == 1 && s[0] == 'x' && a[1] == a[n - 1]
)
){
fi(n){
if (ret[i] == 0) ret[i] = 'S';
if (ret[i] == 1) ret[i] = 'W';
}
ans_end(ret);
}
}
ans(-1);
return wait();
}
| a.cc: In function 'int main()':
a.cc:238:9: error: 'GC' was not declared in this scope; did you mean 'gc'?
238 | GC(s);
| ^~
| gc
|
s760356128 | p03798 | C++ | #define _CRT_SECURE_NO_WARNINGS
#define MATH_PI 3.14159265358979323846264338327950288419716939
#define DIVIDER9 1000000007
#define lli long long int
#include <iostream>
#include <string.h>
#include <fstream>
#include <math.h>
using namespace std;
#ifdef _WIN32
#pragma warning(disable : 4101)
signed wait(){
char wait_dummy[256];
scanf("%c", &wait_dummy);
return 0;
}
template <typename ... Args>
void dout(const char *format, Args const & ... args){
printf(format, args ...);
}
#define MAX_CHARBUF 65536
#define DATAFILE "data.dat"
class csLocalInput{
int FileOpen();
public:
FILE *fp;
csLocalInput();
};
csLocalInput::csLocalInput() {
FileOpen();
}
int csLocalInput::FileOpen() {
fp = fopen(DATAFILE, "rt");
return 1;
}
csLocalInput local_in;
#define DEBUG 1
#else
inline signed wait() { return 0; }
inline void dout(const char *arg, ...) {}
#endif
template<typename T>inline void SWAP(T &a, T &b) { T t = a; a = b; b = t; }
inline void CSWAP(char *&a, char *&b) { char *t = a; a = b; b = t; }
#define CLIP(ptr, min, max) {if((min)<=(max)){if(ptr<(min)){ptr=(min);}if(ptr>(max)){ptr=(max);}}}
#define Sin(deg) sin((deg)*MATH_PI/180.0)
#define Cos(deg) cos((deg)*MATH_PI/180.0)
#define Tan(deg) tan((deg)*MATH_PI/180.0)
#define Rad(deg) ((deg)*MATH_PI/180.0)
#define rep(param, num) for(int param=0 ; param<num ; ++param)
#define fi(num) for(int i=0 ; i<num ; ++i)
#define fj(num) for(int j=0 ; j<num ; ++j)
#define fk(num) for(int k=0 ; k<num ; ++k)
#define fl(num) for(int l=0 ; l<num ; ++l)
#define fn(num) for(int n=0 ; n<num ; ++n)
#define ffr(param, num) for(int param=num-1 ; param>=0 ; --param)
#define fir(num) for(int i=num-1 ; i>=0 ; --i)
#define fjr(num) for(int j=num-1 ; j>=0 ; --j)
#define fkr(num) for(int k=num-1 ; k>=0 ; --k)
#define flr(num) for(int l=num-1 ; l>=0 ; --l)
#define fnr(num) for(int n=num-1 ; n>=0 ; --n)
#define gi(p) int p; Gi(p)
#define gi2(p1, p2) int p1, p2; Gi2(p1, p2)
#define gi3(p1, p2, p3) int p1, p2, p3; Gi3(p1, p2, p3)
#define gi4(p1, p2, p3, p4) int p1, p2, p3, p4; Gi4(p1, p2, p3, p4)
#define glli(p) lli p; Glli(p)
#define glli2(p1, p2) lli p1, p2; Glli2(p1, p2)
#define glli3(p1, p2, p3) lli p1, p2, p3; Glli3(p1, p2, p3)
#define glli4(p1, p2, p3, p4) lli p1, p2, p3, p4; Glli4(p1, p2, p3, p4)
#define gf(p) double p; Gf(p);
#define gf2(p1, p2) double p1, p2; Gf2(p1, p2);
#define gf3(p1, p2, p3) double p1, p2, p3; Gf3(p1, p2, p3);
#define gf4(p1, p2, p3, p4) double p1, p2, p3, p4; Gf4(p1, p2, p3, p4);
#define Gi(p) Scanf("%d", p)
#define Gi2(p1, p2) Scanf2("%d %d", p1, p2)
#define Gi3(p1, p2, p3) Scanf3("%d %d %d", p1, p2, p3)
#define Gi4(p1, p2, p3, p4) Scanf4("%d %d %d %d", p1, p2, p3, p4)
#define Glli(p) Scanf("%lld", p)
#define Glli2(p1, p2) Scanf2("%lld %lld", p1, p2)
#define Glli3(p1, p2, p3) Scanf3("%lld %lld %lld", p1, p2, p3)
#define Glli4(p1, p2, p3, p4) Scanf4("%lld %lld %lld %lld", p1, p2, p3, p4)
#define Gf(p) Scanf("%f", p)
#define Gf2(p1, p2) Scanf2("%f %f", p1, p2)
#define Gf3(p1, p2, p3) Scanf3("%f %f %f", p1, p2, p3)
#define Gf4(p1, p2, p3, p4) Scanf4("%f %f %f %f", p1, p2, p3, p4)
#ifdef DEBUG
#define Gc(buf) fscanf(local_in.fp, "%s", buf)
#define Scanf(expr, p) fscanf(local_in.fp, expr, &p)
#define Scanf2(expr, p1, p2) fscanf(local_in.fp, expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) fscanf(local_in.fp, expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) fscanf(local_in.fp, expr, &p1, &p2, &p3, &p4)
#else
#define gc(buf) Scanf("%s", buf)
#define Scanf(expr, p) scanf(expr, &p)
#define Scanf2(expr, p1, p2) scanf(expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) scanf(expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) scanf(expr, &p1, &p2, &p3, &p4)
#endif
#define ans(p) cout << p << endl;
#define ans_end(p) cout << p << endl; return wait();
void CombSort(int N, int *ar, int order_ascending = 1) { int h = int(N / 1.3); int flag; int i; while (true) { flag = 0; for (i = 0; i + h < N; ++i) { if ((order_ascending&&ar[i] > ar[i + h]) || (!order_ascending&&ar[i] < ar[i + h])) { swap<int>(ar[i], ar[i + h]); flag = 1; } }if (h == 1 && !flag)break; if (h == 9 || h == 10) h = 11; if (h > 1)h = int(h / 1.3); } }
void CombSort(int N, lli *ar, int order_ascending = 1) { int h = int(N / 1.3); int flag; int i; while (true) { flag = 0; for (i = 0; i + h < N; ++i) { if ((order_ascending&&ar[i] > ar[i + h]) || (!order_ascending&&ar[i] < ar[i + h])) { swap<lli>(ar[i], ar[i + h]); flag = 1; } }if (h == 1 && !flag)break; if (h == 9 || h == 10) h = 11; if (h > 1)h = int(h / 1.3); } }
int EuclideanAlgorithm(int N, int *ar){
fn(N - 1){
while (true){
if (ar[n] % ar[n + 1] == 0 || ar[n + 1] % ar[n] == 0) {
ar[n + 1] = ar[n] < ar[n + 1] ? ar[n] : ar[n + 1];
break;
}
if (ar[n] > ar[n + 1]) {
ar[n] %= ar[n + 1];
}
else {
ar[n + 1] %= ar[n];
}
}
}
return ar[N - 1];
}
template<typename T>void CombSort(int N, T *ar, int order_ascending = 1) {
int i, flag;
int h = int(N / 1.3);
while (true) {
flag = 0;
for (i = 0; i + h < N; ++i) {
if (
order_ascending && ar[i].SortValue > ar[i + h].SortValue ||
!order_ascending && ar[i].SortValue < ar[i + h].SortValue
) {
swap<T>(ar[i], ar[i + h]);
flag = 1;
}
}
if (h > 1) {
h = int(h / 1.3);
if (h == 9 || h == 10) h = 11;
}
else {
if (!flag) break;
}
}
}
#include <vector>
#include <algorithm>
struct UnionFind {
vector<int> par;
UnionFind(int N) : par(N) {
for (int i = 0; i < N; i++) par[i] = i;
}
int root(int x) {
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(int x, int y) {
int rx = root(x);
int ry = root(y);
if (rx == ry) return;
par[rx] = ry;
}
bool same(int x, int y) {
int rx = root(x);
int ry = root(y);
return rx == ry;
}
};
void Replace(char *c, int len, char before, char after) {
fi(len){
if(c[i] == before) c[i] = after;
}
}
void Replace(char *c, char before, char after){
int len = strlen(c);
Replace(c, len, before, after);
}
class csNode{
public:
csNode(){
}
};
class csStack{
public:
csStack(){
num = 0;
}
void alloc(int size){
param = new int[size];
}
void sort(int order = 1){
if(num > 1) CombSort(num, param, order);
}
int num;
int *param;
void push(int p){
param[num++] = p;
}
};
char s[200010];
char ret[100010];
int a[100010];
signed main() {
gi(n);
Gc(s);
fk(4){
a[0] = k % 2;
a[1] = k / 2;
ret[0] = a[0];
ret[1] = a[1];
for(int i=0 ; i<n-2 ; ++i){
if (a[i + 1] == 0 && s[i + 1] == 'o') a[i + 2] = a[i];
if (a[i + 1] == 0 && s[i + 1] == 'x') a[i + 2] = 1 - a[i];
if (a[i + 1] == 1 && s[i + 1] == 'o') a[i + 2] = 1 - a[i];
if (a[i + 1] == 1 && s[i + 1] == 'x') a[i + 2] = a[i];
ret[i + 2] = a[i + 2];
}
if(
(
a[n - 1] == 0 && s[n - 1] == 'o' && a[0] == a[n - 2] ||
a[n - 1] == 0 && s[n - 1] == 'x' && a[0] == 1 - a[n - 2] ||
a[n - 1] == 1 && s[n - 1] == 'o' && a[0] == 1 - a[n - 2] ||
a[n - 1] == 1 && s[n - 1] == 'x' && a[0] == a[n - 2]
) && (
a[0] == 0 && s[0] == 'o' && a[1] == a[n - 1] ||
a[0] == 0 && s[0] == 'x' && a[1] == 1 - a[n - 1] ||
a[0] == 1 && s[0] == 'o' && a[1] == 1 - a[n - 1] ||
a[0] == 1 && s[0] == 'x' && a[1] == a[n - 1]
)
){
fi(n){
if (ret[i] == 0) ret[i] = 'S';
if (ret[i] == 1) ret[i] = 'W';
}
ans_end(ret);
}
}
ans(-1);
return wait();
}
| a.cc: In function 'int main()':
a.cc:238:9: error: 'Gc' was not declared in this scope; did you mean 'gc'?
238 | Gc(s);
| ^~
| gc
|
s101522965 | p03798 | C++ | #define _CRT_SECURE_NO_WARNINGS
#define MATH_PI 3.14159265358979323846264338327950288419716939
#define DIVIDER9 1000000007
#define lli long long int
#include <iostream>
#include <string.h>
#include <fstream>
#include <math.h>
using namespace std;
#ifdef _WIN32
#pragma warning(disable : 4101)
signed wait(){
char wait_dummy[256];
scanf("%c", &wait_dummy);
return 0;
}
template <typename ... Args>
void dout(const char *format, Args const & ... args){
printf(format, args ...);
}
#define MAX_CHARBUF 65536
#define DATAFILE "data.dat"
class csLocalInput{
int FileOpen();
public:
FILE *fp;
csLocalInput();
};
csLocalInput::csLocalInput() {
FileOpen();
}
int csLocalInput::FileOpen() {
fp = fopen(DATAFILE, "rt");
return 1;
}
csLocalInput local_in;
#define DEBUG 1
#else
inline signed wait() { return 0; }
inline void dout(const char *arg, ...) {}
#endif
template<typename T>inline void SWAP(T &a, T &b) { T t = a; a = b; b = t; }
inline void CSWAP(char *&a, char *&b) { char *t = a; a = b; b = t; }
#define CLIP(ptr, min, max) {if((min)<=(max)){if(ptr<(min)){ptr=(min);}if(ptr>(max)){ptr=(max);}}}
#define Sin(deg) sin((deg)*MATH_PI/180.0)
#define Cos(deg) cos((deg)*MATH_PI/180.0)
#define Tan(deg) tan((deg)*MATH_PI/180.0)
#define Rad(deg) ((deg)*MATH_PI/180.0)
#define rep(param, num) for(int param=0 ; param<num ; ++param)
#define fi(num) for(int i=0 ; i<num ; ++i)
#define fj(num) for(int j=0 ; j<num ; ++j)
#define fk(num) for(int k=0 ; k<num ; ++k)
#define fl(num) for(int l=0 ; l<num ; ++l)
#define fn(num) for(int n=0 ; n<num ; ++n)
#define ffr(param, num) for(int param=num-1 ; param>=0 ; --param)
#define fir(num) for(int i=num-1 ; i>=0 ; --i)
#define fjr(num) for(int j=num-1 ; j>=0 ; --j)
#define fkr(num) for(int k=num-1 ; k>=0 ; --k)
#define flr(num) for(int l=num-1 ; l>=0 ; --l)
#define fnr(num) for(int n=num-1 ; n>=0 ; --n)
#define gi(p) int p; Gi(p)
#define gi2(p1, p2) int p1, p2; Gi2(p1, p2)
#define gi3(p1, p2, p3) int p1, p2, p3; Gi3(p1, p2, p3)
#define gi4(p1, p2, p3, p4) int p1, p2, p3, p4; Gi4(p1, p2, p3, p4)
#define glli(p) lli p; Glli(p)
#define glli2(p1, p2) lli p1, p2; Glli2(p1, p2)
#define glli3(p1, p2, p3) lli p1, p2, p3; Glli3(p1, p2, p3)
#define glli4(p1, p2, p3, p4) lli p1, p2, p3, p4; Glli4(p1, p2, p3, p4)
#define gf(p) double p; Gf(p);
#define gf2(p1, p2) double p1, p2; Gf2(p1, p2);
#define gf3(p1, p2, p3) double p1, p2, p3; Gf3(p1, p2, p3);
#define gf4(p1, p2, p3, p4) double p1, p2, p3, p4; Gf4(p1, p2, p3, p4);
#define Gi(p) Scanf("%d", p)
#define Gi2(p1, p2) Scanf2("%d %d", p1, p2)
#define Gi3(p1, p2, p3) Scanf3("%d %d %d", p1, p2, p3)
#define Gi4(p1, p2, p3, p4) Scanf4("%d %d %d %d", p1, p2, p3, p4)
#define Glli(p) Scanf("%lld", p)
#define Glli2(p1, p2) Scanf2("%lld %lld", p1, p2)
#define Glli3(p1, p2, p3) Scanf3("%lld %lld %lld", p1, p2, p3)
#define Glli4(p1, p2, p3, p4) Scanf4("%lld %lld %lld %lld", p1, p2, p3, p4)
#define Gf(p) Scanf("%f", p)
#define Gf2(p1, p2) Scanf2("%f %f", p1, p2)
#define Gf3(p1, p2, p3) Scanf3("%f %f %f", p1, p2, p3)
#define Gf4(p1, p2, p3, p4) Scanf4("%f %f %f %f", p1, p2, p3, p4)
#ifdef DEBUG
#define Gc(buf) fscanf(local_in.fp, "%s", buf)
#define Scanf(expr, p) fscanf(local_in.fp, expr, &p)
#define Scanf2(expr, p1, p2) fscanf(local_in.fp, expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) fscanf(local_in.fp, expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) fscanf(local_in.fp, expr, &p1, &p2, &p3, &p4)
#else
#define gc(buf) Scanf("%s", buf)
#define Scanf(expr, p) scanf(expr, &p)
#define Scanf2(expr, p1, p2) scanf(expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) scanf(expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) scanf(expr, &p1, &p2, &p3, &p4)
#endif
#define ans(p) cout << p << endl;
#define ans_end(p) cout << p << endl; return wait();
void CombSort(int N, int *ar, int order_ascending = 1) { int h = int(N / 1.3); int flag; int i; while (true) { flag = 0; for (i = 0; i + h < N; ++i) { if ((order_ascending&&ar[i] > ar[i + h]) || (!order_ascending&&ar[i] < ar[i + h])) { swap<int>(ar[i], ar[i + h]); flag = 1; } }if (h == 1 && !flag)break; if (h == 9 || h == 10) h = 11; if (h > 1)h = int(h / 1.3); } }
void CombSort(int N, lli *ar, int order_ascending = 1) { int h = int(N / 1.3); int flag; int i; while (true) { flag = 0; for (i = 0; i + h < N; ++i) { if ((order_ascending&&ar[i] > ar[i + h]) || (!order_ascending&&ar[i] < ar[i + h])) { swap<lli>(ar[i], ar[i + h]); flag = 1; } }if (h == 1 && !flag)break; if (h == 9 || h == 10) h = 11; if (h > 1)h = int(h / 1.3); } }
int EuclideanAlgorithm(int N, int *ar){
fn(N - 1){
while (true){
if (ar[n] % ar[n + 1] == 0 || ar[n + 1] % ar[n] == 0) {
ar[n + 1] = ar[n] < ar[n + 1] ? ar[n] : ar[n + 1];
break;
}
if (ar[n] > ar[n + 1]) {
ar[n] %= ar[n + 1];
}
else {
ar[n + 1] %= ar[n];
}
}
}
return ar[N - 1];
}
template<typename T>void CombSort(int N, T *ar, int order_ascending = 1) {
int i, flag;
int h = int(N / 1.3);
while (true) {
flag = 0;
for (i = 0; i + h < N; ++i) {
if (
order_ascending && ar[i].SortValue > ar[i + h].SortValue ||
!order_ascending && ar[i].SortValue < ar[i + h].SortValue
) {
swap<T>(ar[i], ar[i + h]);
flag = 1;
}
}
if (h > 1) {
h = int(h / 1.3);
if (h == 9 || h == 10) h = 11;
}
else {
if (!flag) break;
}
}
}
#include <vector>
#include <algorithm>
struct UnionFind {
vector<int> par;
UnionFind(int N) : par(N) {
for (int i = 0; i < N; i++) par[i] = i;
}
int root(int x) {
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(int x, int y) {
int rx = root(x);
int ry = root(y);
if (rx == ry) return;
par[rx] = ry;
}
bool same(int x, int y) {
int rx = root(x);
int ry = root(y);
return rx == ry;
}
};
void Replace(char *c, int len, char before, char after) {
fi(len){
if(c[i] == before) c[i] = after;
}
}
void Replace(char *c, char before, char after){
int len = strlen(c);
Replace(c, len, before, after);
}
class csNode{
public:
csNode(){
}
};
class csStack{
public:
csStack(){
num = 0;
}
void alloc(int size){
param = new int[size];
}
void sort(int order = 1){
if(num > 1) CombSort(num, param, order);
}
int num;
int *param;
void push(int p){
param[num++] = p;
}
};
char s[200010];
char ret[100010];
int a[100010];
signed main() {
gi(n);
Gc(s);
fk(4){
a[0] = k % 2;
a[1] = k / 2;
ret[0] = a[0];
ret[1] = a[1];
for(int i=0 ; i<n-2 ; ++i){
if (a[i + 1] == 0 && s[i + 1] == 'o') a[i + 2] = a[i];
if (a[i + 1] == 0 && s[i + 1] == 'x') a[i + 2] = 1 - a[i];
if (a[i + 1] == 1 && s[i + 1] == 'o') a[i + 2] = 1 - a[i];
if (a[i + 1] == 1 && s[i + 1] == 'x') a[i + 2] = a[i];
ret[i + 2] = a[i + 2];
}
if(
(
a[n - 1] == 0 && s[n - 1] == 'o' && a[0] == a[n - 2] ||
a[n - 1] == 0 && s[n - 1] == 'x' && a[0] == 1 - a[n - 2] ||
a[n - 1] == 1 && s[n - 1] == 'o' && a[0] == 1 - a[n - 2] ||
a[n - 1] == 1 && s[n - 1] == 'x' && a[0] == a[n - 2]
) && (
a[0] == 0 && s[0] == 'o' && a[1] == a[n - 1] ||
a[0] == 0 && s[0] == 'x' && a[1] == 1 - a[n - 1] ||
a[0] == 1 && s[0] == 'o' && a[1] == 1 - a[n - 1] ||
a[0] == 1 && s[0] == 'x' && a[1] == a[n - 1]
)
){
fi(n){
if (ret[i] == 0) ret[i] = 'S';
if (ret[i] == 1) ret[i] = 'W';
}
ans_end(ret);
}
}
ans(-1);
return wait();
}
| a.cc: In function 'int main()':
a.cc:238:9: error: 'Gc' was not declared in this scope; did you mean 'gc'?
238 | Gc(s);
| ^~
| gc
|
s626695320 | p03798 | C++ | #include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>
#include <deque>
using namespace std;
using ull = unsigned long long;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define EPS (1e-7)
#define ALL(x) begin(x), end(x)
string solve(const string s) {
// 4種類試せばよい
const auto ret1 = setanimals(s, "SS");
if (ret1 != "-1") {
return ret1;
}
const auto ret2 = setanimals(s, "SW");
if (ret2 != "-1") {
return ret2;
}
const auto ret3 = setanimals(s, "WS");
if (ret3 != "-1") {
return ret3;
}
const auto ret4 = setanimals(s, "WW");
if (ret4 != "-1") {
return ret4;
}
return "-1";
}
string setanimals(const string s, string animals) {
ll index = 1;
while (index < s.size() - 1) {
const char now = s[index];
const char nowanimal = animals[index];
const char beforeanimal = animals[index - 1];
// 途中の場合、矛盾しないように進める。
if (
((nowanimal == 'S') && (now == 'o')) ||
((nowanimal == 'W') && (now == 'x'))
) {
animals += beforeanimal;
} else {
const string afteranimal = (beforeanimal == 'W') ? "S" : "W";
animals += afteranimal;
}
index++;
}
const char now = s[index];
const char nowanimal = animals[index];
const char beforeanimal = animals[index - 1];
const char afteranimal = animals[0];
//最後は成立するか否かを返す
if (
((nowanimal == 'S') && (now == 'o') && (beforeanimal == afteranimal)) ||
((nowanimal == 'S') && (now == 'x') && (beforeanimal != afteranimal)) ||
((nowanimal == 'W') && (now == 'o') && (beforeanimal != afteranimal)) ||
((nowanimal == 'W') && (now == 'x') && (beforeanimal == afteranimal))
) {
return animals;
} else {
return "-1";
}
}
int main() {
ll N;
string s;
cin >> N >> s;
const string ans = solve(s);
cout << ans << endl;
return 0;
} | a.cc: In function 'std::string solve(std::string)':
a.cc:28:27: error: 'setanimals' was not declared in this scope
28 | const auto ret1 = setanimals(s, "SS");
| ^~~~~~~~~~
|
s730658670 | p03798 | C++ | bool ok(char a,char x,char y,char b)
{
if(x=='o'&&y=='S'&&a=='S'&&b=='S')return true;
if(x=='o'&&y=='S'&&a=='W'&&b=='W')return true;
if(x=='x'&&y=='S'&&a=='S'&&b=='W')return true;
if(x=='x'&&y=='S'&&a=='W'&&b=='S')return true;
if(x=='o'&&y=='W'&&a=='S'&&b=='W')return true;
if(x=='o'&&y=='W'&&a=='W'&&b=='S')return true;
if(x=='x'&&y=='W'&&a=='S'&&b=='S')return true;
if(x=='x'&&y=='W'&&a=='W'&&b=='W')return true;
return false;
}
void dfs(int now)
{
if(now==n-1)
{
if(ok(t[n-2],s[n-1],t[n-1],t[0])&&ok(t[n-1],s[0],t[0],t[1]))end_(t);
return;
}
int bef=now-1;
int nxt=now+1;
if(t[now]=='S')
{
if(s[now]=='x')t[nxt]=change(t[bef]);
else t[nxt]=t[bef];
}
else
{
if(s[now]=='o')t[nxt]=change(t[bef]);
else t[nxt]=t[bef];
}
dfs(now+1);
}
int main()
{
cin>>n;
cin>>s;
t=s;
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
t[0]=c[i];
t[1]=c[j];
dfs(1);
}
}
cout<<"-1\n";
return 0;
} | a.cc: In function 'void dfs(int)':
a.cc:15:17: error: 'n' was not declared in this scope
15 | if(now==n-1)
| ^
a.cc:17:23: error: 't' was not declared in this scope
17 | if(ok(t[n-2],s[n-1],t[n-1],t[0])&&ok(t[n-1],s[0],t[0],t[1]))end_(t);
| ^
a.cc:17:30: error: 's' was not declared in this scope
17 | if(ok(t[n-2],s[n-1],t[n-1],t[0])&&ok(t[n-1],s[0],t[0],t[1]))end_(t);
| ^
a.cc:17:77: error: 'end_' was not declared in this scope
17 | if(ok(t[n-2],s[n-1],t[n-1],t[0])&&ok(t[n-1],s[0],t[0],t[1]))end_(t);
| ^~~~
a.cc:22:12: error: 't' was not declared in this scope
22 | if(t[now]=='S')
| ^
a.cc:24:20: error: 's' was not declared in this scope
24 | if(s[now]=='x')t[nxt]=change(t[bef]);
| ^
a.cc:24:39: error: 'change' was not declared in this scope
24 | if(s[now]=='x')t[nxt]=change(t[bef]);
| ^~~~~~
a.cc:29:20: error: 's' was not declared in this scope
29 | if(s[now]=='o')t[nxt]=change(t[bef]);
| ^
a.cc:29:39: error: 'change' was not declared in this scope
29 | if(s[now]=='o')t[nxt]=change(t[bef]);
| ^~~~~~
a.cc: In function 'int main()':
a.cc:36:9: error: 'cin' was not declared in this scope
36 | cin>>n;
| ^~~
a.cc:36:14: error: 'n' was not declared in this scope
36 | cin>>n;
| ^
a.cc:37:14: error: 's' was not declared in this scope
37 | cin>>s;
| ^
a.cc:38:9: error: 't' was not declared in this scope
38 | t=s;
| ^
a.cc:43:30: error: 'c' was not declared in this scope
43 | t[0]=c[i];
| ^
a.cc:48:9: error: 'cout' was not declared in this scope
48 | cout<<"-1\n";
| ^~~~
|
s627977833 | p03798 | C | #include<bits/stdc++.h>
using namespace std;
int n;
string s,t;
char c[2]={'W','S'};
void end_(string t)
{
cout<<t;
exit(0);
}
char change(char c)
{
if(c=='S')
return 'W';
else
return 'S';
}
bool ok(char a,char x,char y,char b)
{
if(x=='o'&&y=='S'&&a=='S'&&b=='S')return true;
if(x=='o'&&y=='S'&&a=='W'&&b=='W')return true;
if(x=='x'&&y=='S'&&a=='S'&&b=='W')return true;
if(x=='x'&&y=='S'&&a=='W'&&b=='S')return true;
if(x=='o'&&y=='W'&&a=='S'&&b=='W')return true;
if(x=='o'&&y=='W'&&a=='W'&&b=='S')return true;
if(x=='x'&&y=='W'&&a=='S'&&b=='S')return true;
if(x=='x'&&y=='W'&&a=='W'&&b=='W')return true;
return false;
}
void dfs(int now,string t)
{
if(now==n-1)
{
if(ok(t[n-2],s[n-1],t[n-1],t[0])&&ok(t[n-1],s[0],t[0],t[1]))end_(t);
return;
}
int bef=now-1;
int nxt=now+1;
if(t[now]=='S')
{
if(s[now]=='x')t[nxt]=change(t[bef]);
else t[nxt]=t[bef];
}
else
{
if(s[now]=='o')t[nxt]=change(t[bef]);
else t[nxt]=t[bef];
}
dfs(now+1,t);
}
int main()
{
cin>>n;
cin>>s;
t=s;
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
t[0]=c[i];
t[1]=c[j];
dfs(1,t);
}
}
cout<<"-1\n";
return 0;
} | main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
1 | #include<bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s235963570 | p03798 | C++ | #ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;
typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;
/*
__attribute__((constructor))
void initial()
{
cin.tie(NULL);
ios::sync_with_stdio(false);
}
*/
#if 0
int find_par(int x, int par[])
{
if (par[x] == x)
{
return x;
}
else
{
return par[x] = find_par(par[x], par);
}
}
bool same(int x, int y, int par[])
{
if (find_par(x, par) == find_par(y, par))
{
return true;
}
return false;
}
bool is_para(int index, string s, int a[])
{
if (s[index] == 'o')
{
a[index] = 'S';
if ()
}
}
int main()
{
cin.tie(NULL);
ios::sync_with_stdio(false);
int N;
string s;
char a[N];
int par[N];
cin >> N >> s;
for (int i = 0; i < N; i++)
{
par[i] = i;
}
return 0;
}
#endif
/*
bool check(int a[], char hypo1, char hypo2)
{
}
*/
#if 0
int main()
{
cin.tie(NULL);
ios::sync_with_stdio(false);
int N;
string s;
char a[N];
cin >> N >> s;
int i = 0;
for (i = 0; i < 4; i++)
{
memset(a, 0, sizeof(a));
a[0] = i / 2 ? 'W' : 'S';
a[1] = i % 2 ? 'W' : 'S';
int j = 2;
for (; j < N; j++)
{
char tmp = 0;
if (a[j - 1] == 'S')
{
if (a[j - 2] == 'S')
{
if (s[j-1] == 'o')
{
tmp = 'S';
}
else
{
tmp = 'W';
}
}
else
{
if (s[j-1] == 'o')
{
tmp = 'W';
}
else
{
tmp = 'S';
}
}
}
else if (a[j - 1] == 'W')
{
if (a[j - 2] == 'S')
{
if (s[j-1] == 'o')
{
tmp = 'W';
}
else
{
tmp = 'S';
}
}
else
{
if (s[j-1] == 'o')
{
tmp = 'S';
}
else
{
tmp = 'W';
}
}
}
if (a[j] == 0)
{
a[j] = tmp;
}
else
{
if (a[j] != tmp)
{
break;
}
}
}
if (j == N)
{
if (a[N-1] == 'S')
{
if (a[N-2] == 'S')
{
if (s[N-1] == 'o')
{
if (a[0] == 'S')
{
break;
}
}
else
{
if (a[0] == 'W')
{
break;
}
}
}
else
{
if (s[N-1] == 'o')
{
if (a[0] == 'W')
{
break;
}
}
else
{
if (a[0] == 'S')
{
break;
}
}
}
}
else
{
if (a[N-2] == 'S')
{
if (s[N-1] == 'o')
{
if (a[0] == 'W')
{
break;
}
}
else
{
if (a[0] == 'S')
{
break;
}
}
}
else
{
if (s[N-1] == 'o')
{
if (a[0] == 'S')
{
break;
}
}
else
{
if (a[0] == 'W')
{
break;
}
}
}
}
}
}
if (i < 4)
{
rep(i, N)
{
cout << a[i];
}
cout << endl;
}
else
{
cout << -1 << endl;
}
return 0;
}
#endif
int main(){
ios_base::sync_with_stdio(false); //Fast I/O
cin.tie(0);
cout.tie(0);
int n;
char s[100005];
bool A[100005];
cin >> n >> s;
s[n]=s[0];
s[n+1]=s[1];
FOR(i,0,4){
A[0]=i&1;
A[1]=(i>>1)&1;
for(int i=2;i<n+2;i++){
// sheep and x || wolf and o
if(A[i-1]^(s[i-1]=='o'))
A[i]=A[i-2]^1;
else
A[i]=A[i-2];
}
if(A[n]==A[0] && A[n+1]==A[1]){
FOR(i,0,n){
if(A[i])
cout << 'S';
else
cout << "W";
}
return 0;
}
}
cout << -1 << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:288:13: error: 'i' was not declared in this scope
288 | FOR(i,0,4){
| ^
a.cc:288:9: error: 'FOR' was not declared in this scope
288 | FOR(i,0,4){
| ^~~
|
s981735713 | p03798 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(void){
int n, flg=0;
string s, ss, str[4]={"SS","SW","WS","WW"};
cin >> n >> s;
for(int i=0;i<4;++i){
ss = str[i];
for(int j=1;j<s.size();++j){
if(ss[j]=="S"){
if(ss[j-1]=="S"){
if(s[j]=="o"){
ss += "S";
}else{
ss += "W";
}
}else{
if(s[j]=="o"){
ss += "W";
}else{
ss += "S";
}
}
}else{
if(ss[j-1]=="S"){
if(s[j]=="o"){
ss += "W";
}else{
ss += "S";
}
}else{
if(s[j]=="o"){
ss += "S";
}else{
ss += "W";
}
}
}
}
if(ss[0]=="S"){
if(ss[1]==ss[n-1]){
if(s[0]=='o'){
flg = 1;
break;
}
}else{
if(s[0]=='x'){
flg = 1;
break;
}
}
}else{
if(ss[1]==ss[n-1]){
if(s[0]=='x'){
flg = 1;
break;
}
}else{
if(s[0]=='o'){
flg = 1;
break;
}
}
}
}
if(flg) cout << ss << endl;
else cout << "-1" << endl
} | a.cc: In function 'int main()':
a.cc:13:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
13 | if(ss[j]=="S"){
a.cc:14:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
14 | if(ss[j-1]=="S"){
a.cc:15:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
15 | if(s[j]=="o"){
a.cc:21:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
21 | if(s[j]=="o"){
a.cc:28:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
28 | if(ss[j-1]=="S"){
a.cc:29:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
29 | if(s[j]=="o"){
a.cc:35:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
35 | if(s[j]=="o"){
a.cc:43:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
43 | if(ss[0]=="S"){
a.cc:70:28: error: expected ';' before '}' token
70 | else cout << "-1" << endl
| ^
| ;
71 | }
| ~
|
s062756244 | p03798 | C++ | #include<bits/stdc++.h>
using namespace std;
int n;
string s;
vector<char> a,b,c,d;
int main(){
cin>>n>>s;
a.push_back('S');
a.push_back('S');
b.push_back('S');
b.push_back('W');
c.push_back('W');
c.push_back('S');
d.push_back('W');
d.push_back('W');
for(int i=1;i<n;i++){
if(a[i]=='S'){
if(s[i]=='o'){
if(a[i-1]=='S'){
a.push_back('S');
}else{
a.push_back('W');
}
}else{
if(a[i-1]=='S'){
a.push_back('W');
}else{
a.push_back('S');
}
}
}else{
if(s[i]=='o'){
if(a[i-1]=='S'){
a.push_back('W');
}else{
a.push_back('S');
}
}else{
if(a[i-1]=='S'){
a.push_back('S');
}else{
a.push_back('W');
}
}
}
if(b[i]=='S'){
if(s[i]=='o'){
if(b[i-1]=='S'){
b.push_back('S');
}else{
b.push_back('W');
}
}else{
if(b[i-1]=='S'){
b.push_back('W');
}else{
b.push_back('S');
}
}
}else{
if(s[i]=='o'){
if(b[i-1]=='S'){
b.push_back('W');
}else{
b.push_back('S');
}
}else{
if(b[i-1]=='S'){
b.push_back('S');
}else{
b.push_back('W');
}
}
}
if(c[i]=='S'){
if(s[i]=='o'){
if(c[i-1]=='S'){
c.push_back('S');
}else{
c.push_back('W');
}
}else{
if(c[i-1]=='S'){
c.push_back('W');
}else{
c.push_back('S');
}
}
}else{
if(s[i]=='o'){
if(c[i-1]=='S'){
c.push_back('W');
}else{
c.push_back('S');
}
}else{
if(c[i-1]=='S'){
c.push_back('S');
}else{
c.push_back('W');
}
}
}
if(d[i]=='S'){
if(s[i]=='o'){
if(d[i-1]=='S'){
d.push_back('S');
}else{
d.push_back('W');
}
}else{
if(d[i-1]=='S'){
d.push_back('W');
}else{
d.push_back('S');
}
}
}else{
if(s[i]=='o'){
if(d[i-1]=='S'){
d.push_back('W');
}else{
d.push_back('S');
}
}else{
if(d[i-1]=='S'){
d.push_back('S');
}else{
d.push_back('W');
}
}
}
}
if(a.front()==a.back()){
if(s[0]=='o'&&a[1]==a[n-1]||s[0]=='x'&&a[1]!=a[n-1]){
for(int i=0;i<n;i++){
cout<<a[i];
}
return 0;
}
if(b.front()==b.back()){
if(s[0]=='o'&&b[1]==b[n-1]||s[0]=='x'&&b[1]!=b[n-1]){
for(int i=0;i<n;i++){
cout<<b[i];
}
return 0;
}
if(c.front()==c.back()){
if(s[0]=='o'&&c[1]==c[n-1]||s[0]=='x'&&c[1]!=c[n-1]){
for(int i=0;i<n;i++){
cout<<c[i];
}
return 0;
}
if(d.front()==d.back()){
if(s[0]=='o'&&d[1]==d[n-1]||s[0]=='x'&&d[1]!=d[n-1]){
for(int i=0;i<n;i++){
cout<<d[i];
}
return 0;
}
cout<<-1;
} | a.cc: In function 'int main()':
a.cc:163:2: error: expected '}' at end of input
163 | }
| ^
a.cc:148:26: note: to match this '{'
148 | if(c.front()==c.back()){
| ^
a.cc:163:2: error: expected '}' at end of input
163 | }
| ^
a.cc:141:26: note: to match this '{'
141 | if(b.front()==b.back()){
| ^
a.cc:163:2: error: expected '}' at end of input
163 | }
| ^
a.cc:134:26: note: to match this '{'
134 | if(a.front()==a.back()){
| ^
a.cc:163:2: error: expected '}' at end of input
163 | }
| ^
a.cc:6:11: note: to match this '{'
6 | int main(){
| ^
|
s374304135 | p03798 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;
string s;cin>>s;
int a[n+1];
int g=0,h;
vector<int>b={1,1,2,2};
vector<int>c={1,2,1,2};
for(int j=0;j<4;j++){
a[0]=b.at(j);a[1]=c.at(j);
if(a[0]==1){
if(a[1]==1){
if(s[0]=='o'){
h=1;
}
else{
h=2;
}
}
else{
if(s[0]=='o'){
h=2;
}
else{
h=1;
}
}
}
else{
if(a[1]==1){
if(s[0]=='o'){
h=2;
}
else{
h=1;
}
}
else{
if(s[0]=='o'){
h=1;
}
else{
h=2;
}
}
}
}
for(int i=1;i<n;i++){
if(a[i]==1){
if(a[i-1]==1){
if(s[i]=='o'){
a[i+1]=1;
}
else{
a[i+1]=2;
}
}
else{
if(s[i]=='o'){
a[i+1]=2;
}
else{
a[i+1]=1;
}
}
}
else{
if(a[i-1]==1){
if(s[i]=='o'){
a[i+1]=2;
}
else{
a[i+1]=1;
}
}
else{
if(s[i]=='o'){
a[i+1]=1;
}
else{
a[i+1]=2;
}
}
}
}
if(a[n]==a[0]&&h==a[n-1]){
g=1;
break;
}
}
if(g==1){
for(int i=0;i<n;i++){
if(a[i]==1) cout<<"S";
else cout<<"W";
}
}
else if(g==0)
cout<<-1<<endl;
}
| a.cc: In function 'int main()':
a.cc:89:7: error: break statement not within loop or switch
89 | break;
| ^~~~~
a.cc: At global scope:
a.cc:92:3: error: expected unqualified-id before 'if'
92 | if(g==1){
| ^~
a.cc:98:3: error: expected unqualified-id before 'else'
98 | else if(g==0)
| ^~~~
a.cc:100:1: error: expected declaration before '}' token
100 | }
| ^
|
s992133306 | p03798 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;
string s;cin>>s;
int a[n+1];
int g=0,h;
vector<int>b={1,1,2,2};
vector<int>c={1,2,1,2};
for(int j=0;j<4;j++){
a[0]=b.at(j);a[1]=c.at(j);
if(a[0]==1){
if(a[1]==1){
if(s[i]=='o'){
h=1;
}
else{
h=2;
}
}
else{
if(s[i]=='o'){
h=2;
}
else{
h=1;
}
}
}
else{
if(a[1]==1){
if(s[i]=='o'){
h=2;
}
else{
h=1;
}
}
else{
if(s[i]=='o'){
h=1;
}
else{
h=2;
}
}
}
}
for(int i=1;i<n;i++){
if(a[i]==1){
if(a[i-1]==1){
if(s[i]=='o'){
a[i+1]=1;
}
else{
a[i+1]=2;
}
}
else{
if(s[i]=='o'){
a[i+1]=2;
}
else{
a[i+1]=1;
}
}
}
else{
if(a[i-1]==1){
if(s[i]=='o'){
a[i+1]=2;
}
else{
a[i+1]=1;
}
}
else{
if(s[i]=='o'){
a[i+1]=1;
}
else{
a[i+1]=2;
}
}
}
}
if(a[n]==a[0]&&h==a[n-1]){
g=1;
break;
}
}
if(g==1){
for(int i=0;i<n;i++){
if(a[i]==1) cout<<"S";
else cout<<"W";
}
}
else if(g==0)
cout<<-1<<endl;
}
| a.cc: In function 'int main()':
a.cc:14:16: error: 'i' was not declared in this scope
14 | if(s[i]=='o'){
| ^
a.cc:22:16: error: 'i' was not declared in this scope
22 | if(s[i]=='o'){
| ^
a.cc:32:16: error: 'i' was not declared in this scope
32 | if(s[i]=='o'){
| ^
a.cc:40:16: error: 'i' was not declared in this scope
40 | if(s[i]=='o'){
| ^
a.cc:89:7: error: break statement not within loop or switch
89 | break;
| ^~~~~
a.cc: At global scope:
a.cc:92:3: error: expected unqualified-id before 'if'
92 | if(g==1){
| ^~
a.cc:98:3: error: expected unqualified-id before 'else'
98 | else if(g==0)
| ^~~~
a.cc:100:1: error: expected declaration before '}' token
100 | }
| ^
|
s606300280 | p03798 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a,int b){
if(b==0)return a;
return gcd(b,a%b);
}
int lcm(int a,int b){
return a/gcd(a,b)*b;
}
int n,ok=-1;
string s;
string ans[4]={"SS","SW","WS","WW"};
signed main(){
cin>>n>>s;
rep(i,4){
for(int j=1;j<n;j++){
if((s[j]=='o')^(ans[i][j-1]==ans[i][j]))ans+='W';
else ans[i]+='S';
}
if(ans[i][0]==ans[i][n]&&((s[0]=='o')^(ans[i][0]=='S')^(ans[i][1]==ans[i][n-1])))ok=i;
}
if(ok==-1)cout<<-1<<endl;
else cout<<ans[ok].substr(0,n)<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:20:56: error: incompatible types in assignment of 'char' to 'std::string [4]' {aka 'std::__cxx11::basic_string<char> [4]'}
20 | if((s[j]=='o')^(ans[i][j-1]==ans[i][j]))ans+='W';
| ~~~^~~~~
|
s092054449 | p03798 | C++ | #include <cstdio>
#include <string>
using namespace std;
int n;
bool *isO;
char *ans;
void assign(char zero, char one) {
char a[n];
a[0] = zero;
a[1] = one;
for (int i = 2; i < n; i++) {
if ((a[i-1] == 'S') == isO[i-1]) {
a[i] = a[i-2];
} else {
if (a[i-2] == 'S') {
a[i] = 'W';
} else {
a[i] = 'S';
}
}
}
if (a[0] == 'S' && a[n-1] == 'S') {
if (!((a[1] == a[n-1]) ^ isO[0]) && !((a[0] == a[n-2]) ^ isO[n-1])) {
strcpy(ans, a);
}
} else if (a[0] == 'S' && a[n-1] == 'W') {
if (!((a[1] == a[n-1]) ^ isO[0]) && !((a[0] != a[n-2]) ^ isO[n-1])) {
strcpy(ans, a);
}
} else if (a[0] == 'W' && a[n-1] == 'S') {
if (!((a[1] != a[n-1]) ^ isO[0]) && !((a[0] == a[n-2]) ^ isO[n-1])) {
strcpy(ans, a);
}
} else if (a[0] == 'W' && a[n-1] == 'W') {
if (!((a[1] != a[n-1]) ^ isO[0]) && !((a[0] != a[n-2]) ^ isO[n-1])) {
strcpy(ans, a);
}
}
return;
}
int main() {
scanf("%d", &n);
char s[n];
scanf("%s", s);
ans = new char[n];
isO = new bool[n];
for (int i = 0; i < n; i++) {
isO[i] = (s[i] == 'o');
}
char sw[] = "SW";
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
if (*ans == 0) {
assign(sw[i], sw[j]);
}
}
}
if (*ans == 0) { strcpy(ans, "-1"); }
printf("%s\n", ans);
return 0;
} | a.cc: In function 'void assign(char, char)':
a.cc:27:13: error: 'strcpy' was not declared in this scope
27 | strcpy(ans, a);
| ^~~~~~
a.cc:3:1: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <string>
+++ |+#include <cstring>
3 | using namespace std;
a.cc:31:13: error: 'strcpy' was not declared in this scope
31 | strcpy(ans, a);
| ^~~~~~
a.cc:31:13: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:35:13: error: 'strcpy' was not declared in this scope
35 | strcpy(ans, a);
| ^~~~~~
a.cc:35:13: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:39:13: error: 'strcpy' was not declared in this scope
39 | strcpy(ans, a);
| ^~~~~~
a.cc:39:13: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc: In function 'int main()':
a.cc:68:22: error: 'strcpy' was not declared in this scope
68 | if (*ans == 0) { strcpy(ans, "-1"); }
| ^~~~~~
a.cc:68:22: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s944463187 | p03798 | C++ | #include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9
int main() {
int n;
cin >> n;
string s;
cin >> s;
bool ans = false;
vector<char> v(100005);
v[1] = 'S'; v[2] = 'S';
for (int i = 2;i < n;i++) {
if (v[i] == 'S'&&s[i - 1] == 'o') v[i + 1] = v[i - 1];
if (v[i] == 'W'&&s[i - 1] == 'x') v[i + 1] = v[i - 1];
if (v[i] == 'S'&&s[i - 1] == 'x') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
if (v[i] == 'W'&&s[i - 1] == 'o') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
}
if (v[n] == 'S'&&s[n - 1] == 'o') if (v[n - 1] == v[1]) ans = true;
if (v[n] == 'S'&&s[n - 1] == 'x') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'o') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'x') if (v[n - 1] == v[1]) ans = true;
if (ans == true) { for (int i = 1;i <= n;i++) cout << v[i];cout << endl; return 0; }
vector<char> v(100005);
v[1] = 'W'; v[2] = 'S';
for (int i = 2;i < n;i++) {
if (v[i] == 'S'&&s[i - 1] == 'o') v[i + 1] = v[i - 1];
if (v[i] == 'W'&&s[i - 1] == 'x') v[i + 1] = v[i - 1];
if (v[i] == 'S'&&s[i - 1] == 'x') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
if (v[i] == 'W'&&s[i - 1] == 'o') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
}
if (v[n] == 'S'&&s[n - 1] == 'o') if (v[n - 1] == v[1]) ans = true;
if (v[n] == 'S'&&s[n - 1] == 'x') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'o') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'x') if (v[n - 1] == v[1]) ans = true;
if (ans == true) { for (int i = 1;i <= n;i++) cout << v[i]; cout << endl;return 0; }
vector<char> v(100005);
v[1] = 'S'; v[2] = 'W';
for (int i = 2;i < n;i++) {
if (v[i] == 'S'&&s[i - 1] == 'o') v[i + 1] = v[i - 1];
if (v[i] == 'W'&&s[i - 1] == 'x') v[i + 1] = v[i - 1];
if (v[i] == 'S'&&s[i - 1] == 'x') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
if (v[i] == 'W'&&s[i - 1] == 'o') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
}
if (v[n] == 'S'&&s[n - 1] == 'o') if (v[n - 1] == v[1]) ans = true;
if (v[n] == 'S'&&s[n - 1] == 'x') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'o') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'x') if (v[n - 1] == v[1]) ans = true;
if (ans == true) { for (int i = 1;i <= n;i++) cout << v[i]; cout << endl;return 0; }
vector<char> v(100005);
v[1] = 'W'; v[2] = 'W';
for (int i = 2;i < n;i++) {
if (v[i] == 'S'&&s[i - 1] == 'o') v[i + 1] = v[i - 1];
if (v[i] == 'W'&&s[i - 1] == 'x') v[i + 1] = v[i - 1];
if (v[i] == 'S'&&s[i - 1] == 'x') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
if (v[i] == 'W'&&s[i - 1] == 'o') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
}
if (v[n] == 'S'&&s[n - 1] == 'o') if (v[n - 1] == v[1]) ans = true;
if (v[n] == 'S'&&s[n - 1] == 'x') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'o') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'x') if (v[n - 1] == v[1]) ans = true;
if (ans == true) { for (int i = 1;i <= n;i++) cout << v[i]; cout << endl;return 0; }
cout << -1 << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:35:22: error: redeclaration of 'std::vector<char> v'
35 | vector<char> v(100005);
| ^
a.cc:21:22: note: 'std::vector<char> v' previously declared here
21 | vector<char> v(100005);
| ^
a.cc:49:22: error: redeclaration of 'std::vector<char> v'
49 | vector<char> v(100005);
| ^
a.cc:21:22: note: 'std::vector<char> v' previously declared here
21 | vector<char> v(100005);
| ^
a.cc:63:22: error: redeclaration of 'std::vector<char> v'
63 | vector<char> v(100005);
| ^
a.cc:21:22: note: 'std::vector<char> v' previously declared here
21 | vector<char> v(100005);
| ^
|
s468070147 | p03798 | C++ | #include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9
int main() {
int n;
cin >> n;
string s;
cin >> s;
bool ans = false;
vector<char> v;
v[1] = 'S'; v[2] = 'S';
for (int i = 2;i < n;i++) {
if (v[i] == 'S'&&s[i - 1] == 'o') v[i + 1] = v[i - 1];
if (v[i] == 'W'&&s[i - 1] == 'x') v[i + 1] = v[i - 1];
if (v[i] == 'S'&&s[i - 1] == 'x') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
if (v[i] == 'W'&&s[i - 1] == 'o') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
}
if (v[n] == 'S'&&s[n - 1] == 'o') if (v[n - 1] == v[1]) ans = true;
if (v[n] == 'S'&&s[n - 1] == 'x') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'o') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'x') if (v[n - 1] == v[1]) ans = true;
if (ans == true) { for (int i = 1;i <= n;i++) cout << v[i];cout << endl; return 0; }
vector<char> v;
v[1] = 'W'; v[2] = 'S';
for (int i = 2;i < n;i++) {
if (v[i] == 'S'&&s[i - 1] == 'o') v[i + 1] = v[i - 1];
if (v[i] == 'W'&&s[i - 1] == 'x') v[i + 1] = v[i - 1];
if (v[i] == 'S'&&s[i - 1] == 'x') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
if (v[i] == 'W'&&s[i - 1] == 'o') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
}
if (v[n] == 'S'&&s[n - 1] == 'o') if (v[n - 1] == v[1]) ans = true;
if (v[n] == 'S'&&s[n - 1] == 'x') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'o') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'x') if (v[n - 1] == v[1]) ans = true;
if (ans == true) { for (int i = 1;i <= n;i++) cout << v[i]; cout << endl;return 0; }
vector<char> v;
v[1] = 'S'; v[2] = 'W';
for (int i = 2;i < n;i++) {
if (v[i] == 'S'&&s[i - 1] == 'o') v[i + 1] = v[i - 1];
if (v[i] == 'W'&&s[i - 1] == 'x') v[i + 1] = v[i - 1];
if (v[i] == 'S'&&s[i - 1] == 'x') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
if (v[i] == 'W'&&s[i - 1] == 'o') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
}
if (v[n] == 'S'&&s[n - 1] == 'o') if (v[n - 1] == v[1]) ans = true;
if (v[n] == 'S'&&s[n - 1] == 'x') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'o') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'x') if (v[n - 1] == v[1]) ans = true;
if (ans == true) { for (int i = 1;i <= n;i++) cout << v[i]; cout << endl;return 0; }
vector<char> v;
v[1] = 'W'; v[2] = 'W';
for (int i = 2;i < n;i++) {
if (v[i] == 'S'&&s[i - 1] == 'o') v[i + 1] = v[i - 1];
if (v[i] == 'W'&&s[i - 1] == 'x') v[i + 1] = v[i - 1];
if (v[i] == 'S'&&s[i - 1] == 'x') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
if (v[i] == 'W'&&s[i - 1] == 'o') if (v[i - 1] == 'S') v[i + 1] = 'W';else v[i + 1] = 'S';
}
if (v[n] == 'S'&&s[n - 1] == 'o') if (v[n - 1] == v[1]) ans = true;
if (v[n] == 'S'&&s[n - 1] == 'x') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'o') if (v[n - 1] != v[1]) ans = true;
if (v[n] == 'W'&&s[n - 1] == 'x') if (v[n - 1] == v[1]) ans = true;
if (ans == true) { for (int i = 1;i <= n;i++) cout << v[i]; cout << endl;return 0; }
cout << -1 << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:35:22: error: redeclaration of 'std::vector<char> v'
35 | vector<char> v;
| ^
a.cc:21:22: note: 'std::vector<char> v' previously declared here
21 | vector<char> v;
| ^
a.cc:49:22: error: redeclaration of 'std::vector<char> v'
49 | vector<char> v;
| ^
a.cc:21:22: note: 'std::vector<char> v' previously declared here
21 | vector<char> v;
| ^
a.cc:63:22: error: redeclaration of 'std::vector<char> v'
63 | vector<char> v;
| ^
a.cc:21:22: note: 'std::vector<char> v' previously declared here
21 | vector<char> v;
| ^
|
s112238847 | p03798 | C++ | #include "bits/stdc++.h"
using namespace std;
int main(){
int n;
cin>>n;
string s;
cin>>s;
string x(n,'0');
x[0]='S';
x[1]='S';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
bool f=true;
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]!=x[0])f&=true;
else f=false;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]==x[0])f&=true;
else f=false;
}
if(s[0]=='o'){
if(x[0]=='S'&&x[n-1]==x[1])f=true;
else if(x[0]=='W'&&x[n-1]!=x[1])f=true;
else f=false;
}else{
if(x[0]=='S'&&x[n-1]!=x[1])f=true;
else if(x[0]=='W'&&x[n-1]==x[1])f=true;
else f=false;
}
if(f){
cout<<x<<endl;
return 0;
}
x[0]='W';
x[1]='S';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
f=true;
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]!=x[0])f&=true;
else f=false;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]==x[0])f&=true;
else f=false;
}
if(s[0]=='o'){
if(x[0]=='S'&&x[n-1]==x[1])f&=true;
else if(x[0]=='W'&&x[n-1]!=x[1])f&=true;
else f=false;
}else{
if(x[0]=='S'&&x[n-1]!=x[1])f&=true;
else if(x[0]=='W'&&x[n-1]==x[1])f&=true;
else f=false;
}
if(f){
cout<<x<<endl;
return 0;
}
x[0]='S';
x[1]='W';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
f=true;
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]!=x[0])f&=true;
else f=false;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]==x[0])f=&true;
else f=false;
}
if(s[0]=='o'){
if(x[0]=='S'&&x[n-1]==x[1])f=&true;
else if(x[0]=='W'&&x[n-1]!=x[1])f=&true;
else f=false;
}else{
if(x[0]=='S'&&x[n-1]!=x[1])f=&true;
else if(x[0]=='W'&&x[n-1]==x[1])f=&true;
else f=false;
}
if(f){
cout<<x<<endl;
return 0;
}
x[0]='W';
x[1]='W';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
f=true;
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]!=x[0])f&=true;
else f=false;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]==x[0])f&=true;
else f=false;
}
if(s[0]=='o'){
if(x[0]=='S'&&x[n-1]==x[1])f&=true;
else if(x[0]=='W'&&x[n-1]!=x[1])f&=true;
else f=false;
}else{
if(x[0]=='S'&&x[n-1]!=x[1])f&=true;
else if(x[0]=='W'&&x[n-1]==x[1])f&=true;
else f=false;
}
if(f){
cout<<x<<endl;
return 0;
}
cout<<-1<<endl;
} | a.cc: In function 'int main()':
a.cc:115:54: error: lvalue required as unary '&' operand
115 | else if(x[n-1]=='W'&&x[n-2]==x[0])f=&true;
| ^~~~
a.cc:120:47: error: lvalue required as unary '&' operand
120 | if(x[0]=='S'&&x[n-1]==x[1])f=&true;
| ^~~~
a.cc:121:52: error: lvalue required as unary '&' operand
121 | else if(x[0]=='W'&&x[n-1]!=x[1])f=&true;
| ^~~~
a.cc:124:47: error: lvalue required as unary '&' operand
124 | if(x[0]=='S'&&x[n-1]!=x[1])f=&true;
| ^~~~
a.cc:125:52: error: lvalue required as unary '&' operand
125 | else if(x[0]=='W'&&x[n-1]==x[1])f=&true;
| ^~~~
|
s259741634 | p03798 | C++ | #include "bits/stdc++.h"
using namespace std;
int main(){
int n;
cin>>n;
string s;
cin>>s;
string x(n,'0');
x[0]='S';
x[1]='S';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
f=true;
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]!=x[0])f&=true;
else f=false;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]==x[0])f&=true;
else f=false;
}
if(s[0]=='o'){
if(x[0]=='S'&&x[n-1]==x[1])f&=true;
else if(x[0]=='W'&&x[n-1]!=x[1])f&=true;
else f=false;
}else{
if(x[0]=='S'&&x[n-1]!=x[1])f&=true;
else if(x[0]=='W'&&x[n-1]==x[1])f&=true;
else f=false;
}
if(f){
cout<<x<<endl;
return 0;
}
x[0]='S';
x[1]='W';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
f=true;
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]!=x[0])f&=true;
else f=false;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]==x[0])f&=true;
else f=false;
}
if(s[0]=='o'){
if(x[0]=='S'&&x[n-1]==x[1])f&=true;
else if(x[0]=='W'&&x[n-1]!=x[1])f&=true;
else f=false;
}else{
if(x[0]=='S'&&x[n-1]!=x[1])f&=true;
else if(x[0]=='W'&&x[n-1]==x[1])f&=true;
else f=false;
}
if(f){
cout<<x<<endl;
return 0;
}
x[0]='W';
x[1]='S';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
f=true;
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]!=x[0])f&=true;
else f=false;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]==x[0])f&=true;
else f=false;
}
if(s[0]=='o'){
if(x[0]=='S'&&x[n-1]==x[1])f&=true;
else if(x[0]=='W'&&x[n-1]!=x[1])f&=true;
else f=false;
}else{
if(x[0]=='S'&&x[n-1]!=x[1])f&=true;
else if(x[0]=='W'&&x[n-1]==x[1])f&=true;
else f=false;
}
if(f){
cout<<x<<endl;
return 0;
}
x[0]='W';
x[1]='W';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
f=true;
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]!=x[0])f&=true;
else f=false;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f&=true;
else if(x[n-1]=='W'&&x[n-2]==x[0])f&=true;
else f=false;
}
if(s[0]=='o'){
if(x[0]=='S'&&x[n-1]==x[1])f&=true;
else if(x[0]=='W'&&x[n-1]!=x[1])f&=true;
else f=false;
}else{
if(x[0]=='S'&&x[n-1]!=x[1])f&=true;
else if(x[0]=='W'&&x[n-1]==x[1])f&=true;
else f=false;
}
if(f){
cout<<x<<endl;
return 0;
}
cout<<-1<<endl;
}
| a.cc: In function 'int main()':
a.cc:26:9: error: 'f' was not declared in this scope
26 | f=true;
| ^
|
s369031837 | p03798 | C++ | #include "bits/stdc++.h"
using namespace std;
int main(){
int n;
cin>>n;
string s;
cin>>s;
string x(n,'0');
x[0]='S';
x[1]='S';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
bool f=false;
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f=true;
if(x[n-1]=='W'&&x[n-2]!=x[0])f=true;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f=true;
if(x[n-1]=='W'&&x[n-2]==x[0])f=true;
}
if(s[0]=='o'){
if(x[0]=='S'&&x[n-1]==x[1])f&&=true;
if(x[0]=='W'&&x[n-1]!=x[1])f=true;
}else{
if(x[0]=='S'&&x[n-1]!=x[1])f=true;
if(x[0]=='W'&&x[n-1]==x[1])f=true;
}
if(f){
cout<<x<<endl;
return 0;
}
x[0]='S';
x[1]='W';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f=true;
if(x[n-1]=='W'&&x[n-2]!=x[0])f=true;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f=true;
if(x[n-1]=='W'&&x[n-2]==x[0])f=true;
}
if(s[0]=='o'){
if(x[0]=='S'&&x[n-1]==x[1])f&&=true;
if(x[0]=='W'&&x[n-1]!=x[1])f=true;
}else{
if(x[0]=='S'&&x[n-1]!=x[1])f=true;
if(x[0]=='W'&&x[n-1]==x[1])f=true;
}
if(f){
cout<<x<<endl;
return 0;
}
x[0]='W';
x[1]='S';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f=true;
if(x[n-1]=='W'&&x[n-2]!=x[0])f=true;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f=true;
if(x[n-1]=='W'&&x[n-2]==x[0])f=true;
}
if(s[0]=='o'){
if(x[0]=='S'&&x[n-1]==x[1])f&&=true;
if(x[0]=='W'&&x[n-1]!=x[1])f=true;
}else{
if(x[0]=='S'&&x[n-1]!=x[1])f=true;
if(x[0]=='W'&&x[n-1]==x[1])f=true;
}
if(f){
cout<<x<<endl;
return 0;
}
x[0]='W';
x[1]='W';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f=true;
if(x[n-1]=='W'&&x[n-2]!=x[0])f=true;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f=true;
if(x[n-1]=='W'&&x[n-2]==x[0])f=true;
}
if(s[0]=='o'){
if(x[0]=='S'&&x[n-1]==x[1])f&&=true;
if(x[0]=='W'&&x[n-1]!=x[1])f=true;
}else{
if(x[0]=='S'&&x[n-1]!=x[1])f=true;
if(x[0]=='W'&&x[n-1]==x[1])f=true;
}
if(f){
cout<<x<<endl;
return 0;
}
cout<<-1<<endl;
}
| a.cc: In function 'int main()':
a.cc:37:47: error: expected primary-expression before '=' token
37 | if(x[0]=='S'&&x[n-1]==x[1])f&&=true;
| ^
a.cc:73:47: error: expected primary-expression before '=' token
73 | if(x[0]=='S'&&x[n-1]==x[1])f&&=true;
| ^
a.cc:109:47: error: expected primary-expression before '=' token
109 | if(x[0]=='S'&&x[n-1]==x[1])f&&=true;
| ^
a.cc:145:47: error: expected primary-expression before '=' token
145 | if(x[0]=='S'&&x[n-1]==x[1])f&&=true;
| ^
|
s112165089 | p03798 | C++ | #include "bits/stdc++.h"
using namespace std;
int main(){
int n;
cin>>n;
string s;
cin>>s;
string x(n,'0');
x[0]='S';
x[1]='S';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
bool f=false;
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f=true;
if(x[n-1]=='W'&&x[n-2]!=x[0])f=true;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f=true;
if(x[n-1]=='W'&&x[n-2]==x[0])f=true;
}
if(f){
cout<<x<<endl;
return 0;
}
x[0]='S';
x[1]='W';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
bool f=false;
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f=true;
if(x[n-1]=='W'&&x[n-2]!=x[0])f=true;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f=true;
if(x[n-1]=='W'&&x[n-2]==x[0])f=true;
}
if(f){
cout<<x<<endl;
return 0;
}
x[0]='W';
x[1]='S';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
bool f=false;
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f=true;
if(x[n-1]=='W'&&x[n-2]!=x[0])f=true;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f=true;
if(x[n-1]=='W'&&x[n-2]==x[0])f=true;
}
if(f){
cout<<x<<endl;
return 0;
}
x[0]='W';
x[1]='W';
for(int i=1;i<n-1;i++){
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
}
bool f=false;
if(s[n-1]=='o'){
if(x[n-1]=='S'&&x[n-2]==x[0])f=true;
if(x[n-1]=='W'&&x[n-2]!=x[0])f=true;
}else{
if(x[n-1]=='S'&&x[n-2]!=x[0])f=true;
if(x[n-1]=='W'&&x[n-2]==x[0])f=true;
}
if(f){
cout<<x<<endl;
return 0;
}
cout<<-1<<endl;
} | a.cc: In function 'int main()':
a.cc:55:14: error: redeclaration of 'bool f'
55 | bool f=false;
| ^
a.cc:26:14: note: 'bool f' previously declared here
26 | bool f=false;
| ^
a.cc:84:14: error: redeclaration of 'bool f'
84 | bool f=false;
| ^
a.cc:26:14: note: 'bool f' previously declared here
26 | bool f=false;
| ^
a.cc:113:14: error: redeclaration of 'bool f'
113 | bool f=false;
| ^
a.cc:26:14: note: 'bool f' previously declared here
26 | bool f=false;
| ^
|
s868400204 | p03798 | C++ | #include<iostream>
#include<queue>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<functional>
#include<set>
using namespace std;
#define int long long
typedef pair<int, int>P;
int w[4][100005];
signed main() {
int n; cin >> n;
string s; cin >> s;
memset(w, -1, sizeof(w));
w[0][0] = 0, w[0][1] = 0;
w[1][0] = 0, w[1][1] = 1;
w[2][0] = 1, w[2][1] = 0;
w[3][0] = 1, w[3][1] = 1;
int fl = 0,ans=4;
//0=sheep,1=wolf
for (int i = 0; i < 4; i++) {
for (int j = 1; j <= n; j++) {
int m = j%n, l = (j + n - 1) % n, r = (j + 1) % n;
if (w[i][m]) {//.wolf
if (s[m] == 'o') {
int a;
if (w[i][l])a = 0;
else a = 1;
if (w[i][r] ==-1)w[i][r] = a;
else if (w[i][r] != a)fl++;
}
else {
int a;
if (w[i][l])a = 1;
else a = 0;
if (w[i][r] == -1)w[i][r] = a;
else if (w[i][r] != a)fl++;
}
}
else {
if (s[m] == 'x') {
int a;
if (w[i][l])a = 0;
else a = 1;
if (w[i][r] == -1)w[i][r] = a;
else if (w[i][r] != a)fl++;
}
else {
int a;
if (w[i][l])a = 1;
else a = 0;
if (w[i][r] == -1)w[i][r] = a;
else if (w[i][r] != a)fl++;
}
}
}
if (!fl)ans = i;
fl = 0;
}
if (ans == 4)puts("-1");
else {
for (int i = 0; i < n; i++) {
if (w[ans][i])cout << 'W';
else cout << 'S';
}
cout << endl;
}
} | a.cc: In function 'int main()':
a.cc:17:9: error: 'memset' was not declared in this scope
17 | memset(w, -1, sizeof(w));
| ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
9 | #include<set>
+++ |+#include <cstring>
10 | using namespace std;
|
s585224280 | p03798 | C++ | #include<iostream>
#include<string>
using namespace std;
int main(){
int n,a=0,b=[100000];
string s;
cin>>n>>s;
for(int i=1;i<n;i++)
{
if(s[i]=="x")
{a++
b[a]=i;}
}
if(a%2==1){
cout<<"-1";
return 0}
for(int i=0;i<a;i=i+2)
{
for(int j=b[i]+1;j<b[i+1];j++)
{s[j]="w";}}
cout<<s;
return 0;
} | a.cc: In function 'int main()':
a.cc:5:14: error: expected identifier before numeric constant
5 | int n,a=0,b=[100000];
| ^~~~~~
a.cc: In lambda function:
a.cc:5:21: error: expected '{' before ';' token
5 | int n,a=0,b=[100000];
| ^
a.cc: In function 'int main()':
a.cc:5:13: error: invalid user-defined conversion from 'main()::<lambda()>' to 'int' [-fpermissive]
5 | int n,a=0,b=[100000];
| ^~~~~~~~
a.cc:5:13: note: candidate is: 'constexpr main()::<lambda()>::operator void (*)()() const' (near match)
5 | int n,a=0,b=[100000];
| ^
a.cc:5:13: note: no known conversion from 'void (*)()' to 'int'
a.cc:10:8: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
10 | if(s[i]=="x")
a.cc:11:5: error: expected ';' before 'b'
11 | {a++
| ^
| ;
12 | b[a]=i;}
| ~
a.cc:16:9: error: expected ';' before '}' token
16 | return 0}
| ^
| ;
a.cc:19:12: error: invalid types 'int[int]' for array subscript
19 | for(int j=b[i]+1;j<b[i+1];j++)
| ^
a.cc:19:21: error: invalid types 'int[int]' for array subscript
19 | for(int j=b[i]+1;j<b[i+1];j++)
| ^
a.cc:20:7: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive]
20 | {s[j]="w";}}
| ^~~
| |
| const char*
|
s715944300 | p03798 | C++ | #include<cstdio>
#include<iostream>
using namespace std;
char ans[10001],spe[10001];
int n;
bool c(char l)
{
switch(l)
{
case 'o':return true;
case 'x':return false;
case 'S':return true;
case 'W':return false;
}
}
char c(bool l){return (l?'S':'W');}
char func(int i,int j)
{return (c((c(spe[i])==c(ans[i]))==(c(spe[j]))));}
bool comp(char f,char s)
{
int i;
spe[0]=f;spe[1]=s;
for(i=2;i<n;i++)
{spe[i]==func[i];}
return (func(n-1,n-2)==spe[0]&&func(0,n-1)==spe[1]);
}
int main()
{
cin>>n>>ans;
if(comp('S','S'))
{cout<<spe;return 0;}
if(comp('S','W'))
{cout<<spe;return 0;}
if(comp('W','S'))
{cout<<spe;return 0;}
if(comp('W','W'))
{cout<<spe;return 0;}
cout<<"-1";
return 0;
}
| a.cc: In function 'bool comp(char, char)':
a.cc:24:16: warning: pointer to a function used in arithmetic [-Wpointer-arith]
24 | {spe[i]==func[i];}
| ^
a.cc:24:8: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
24 | {spe[i]==func[i];}
| ~~~~~~^~~~~~~~~
a.cc: In function 'bool c(char)':
a.cc:15:1: warning: control reaches end of non-void function [-Wreturn-type]
15 | }
| ^
|
s922758877 | p03798 | C++ | #include<cstdio>
#include<iostream>
using namespace std;
char ans[10001],spe[10001];
int n;
bool c(char l)
{
switch(l)
{
case 'o':return true;
case 'x':return false;
case 'S':return true;
case 'W':return false;
}
}
char c(bool l){return (l?'S':'W');}
char func(int i,int j)
{return (c((c(spe[i])==c(ans[i]))==(c(spe[j]))));}
bool comp(char f,char s)
{
int i;
spe[0]=f;spe[1]=s;
for(i=2;i<n;i++)
{spe[i]=func[i];}
return (func(n-1,n-2)==spe[0]&&func(0,n-1)==spe[1]);
}
int main()
{
cin>>n>>ans;
if(comp('S','S'))
{cout<<spe;return 0;}
if(comp('S','W'))
{cout<<spe;return 0;}
if(comp('W','S'))
{cout<<spe;return 0;}
if(comp('W','W'))
{cout<<spe;return 0;}
cout<<"-1";
return 0;
}
| a.cc: In function 'bool comp(char, char)':
a.cc:24:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
24 | {spe[i]=func[i];}
| ^
a.cc:24:15: error: invalid conversion from 'char (*)(int, int)' to 'char' [-fpermissive]
24 | {spe[i]=func[i];}
| ~~~~~~^
| |
| char (*)(int, int)
a.cc: In function 'bool c(char)':
a.cc:15:1: warning: control reaches end of non-void function [-Wreturn-type]
15 | }
| ^
|
s428143873 | p03798 | C++ | #include<cstdio>
#include<iostream>
using namespace std;
char ans[10001],spe[10001];
bool c(char l)
{
switch(l)
{
case 'o':return true;
case 'x':return false;
case 'S':return true;
case 'W':return false;
}
}
char c(bool l){return (l?'S':'W');}
char func(int i,int j)
{return (c((c(spe[i])==c(ans[i]))==(c(spe[j]))));}
bool comp(char f,char s)
{
int i;
spe[0]=f;spe[1]=s;
for(i=2;i<n;i++)
{spe[i]=func[i];}
return (func(n-1,n-2)==spe[0]&&func(0,n-1)==spe[1]);
}
int main()
{
int n;
cin>>n>>ans;
if(comp('S','S'))
{cout<<spe;return 0;}
if(comp('S','W'))
{cout<<spe;return 0;}
if(comp('W','S'))
{cout<<spe;return 0;}
if(comp('W','W'))
{cout<<spe;return 0;}
cout<<"-1";
return 0;
}
| a.cc: In function 'bool comp(char, char)':
a.cc:22:11: error: 'n' was not declared in this scope
22 | for(i=2;i<n;i++)
| ^
a.cc:23:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
23 | {spe[i]=func[i];}
| ^
a.cc:23:15: error: invalid conversion from 'char (*)(int, int)' to 'char' [-fpermissive]
23 | {spe[i]=func[i];}
| ~~~~~~^
| |
| char (*)(int, int)
a.cc:24:14: error: 'n' was not declared in this scope
24 | return (func(n-1,n-2)==spe[0]&&func(0,n-1)==spe[1]);
| ^
a.cc: In function 'bool c(char)':
a.cc:14:1: warning: control reaches end of non-void function [-Wreturn-type]
14 | }
| ^
|
s363490199 | p03798 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;
int main(){
int n;
string s;
cin>>n>>s;
string ans(n,'S');
if(s[0]=='o'){
ans[1]='S';ans[n-1]='S';
FOR(i,1,n){
if(s[i]=='o'&&ans[i]=='S'||s[i]=='x'&&ans[i]=='W'){
if(i==n-1){
if(ans[0]==ans[i-1]){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i-1];
}
else{
if(i==n-1){
if(ans[0]==(ans[i-1]=='S'?'W':'S')){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i-1]=='S'?'W':'S';
}
}
ans[1]='W';ans[n-1]='W';
FOR(i,1,n){
if(s[i]=='o'&&ans[i]=='S'||s[i]=='x'&&ans[i]=='W'){
if(i==n-1){
if(ans[0]==ans[i-1]){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i-1];
}
else{
if(i==n-1){
if(ans[0]==(ans[i-1]=='S'?'W':'S')){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i-1]=='S'?'W':'S';
}
}
}
else{
ans[1]='S';ans[n-1]='W';
FOR(i,1,n){
if(s[i]=='o'&&ans[i]=='S'||s[i]=='x'&&ans[i]=='W'){
if(i==n-1){
if(ans[0]==ans[i-1]){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i];
}
else{
if(i==n-1){
if(ans[0]==(ans[i-1]=='S'?'W':'S')){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i]=='S'?'W':'S';
}
}
ans[1]='W';ans[n-1]='S';
FOR(i,1,n){
if(s[i]=='o'&&ans[i]=='S'||s[i]=='x'&&ans[i]=='W'){
if(i==n-1){
if(ans[0]==ans[i-1]){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i];
}
else{
if(i==n-1){
if(ans[0]==(ans[i-1]=='S'?'W':'S')){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i]=='S'?'W':'S';
}
}
}
string ans(n,'W');
if(s[0]=='o'){
ans[1]='W';ans[n-1]='S';
FOR(i,1,n){
if(s[i]=='o'&&ans[i]=='S'||s[i]=='x'&&ans[i]=='W'){
if(i==n-1){
if(ans[0]==ans[i-1]){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i-1];
}
else{
if(i==n-1){
if(ans[0]==(ans[i-1]=='S'?'W':'S')){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i-1]=='S'?'W':'S';
}
}
ans[1]='S';ans[n-1]='W';
FOR(i,1,n){
if(s[i]=='o'&&ans[i]=='S'||s[i]=='x'&&ans[i]=='W'){
if(i==n-1){
if(ans[0]==ans[i-1]){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i-1];
}
else{
if(i==n-1){
if(ans[0]==(ans[i-1]=='S'?'W':'S')){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i-1]=='S'?'W':'S';
}
}
}
else{
ans[1]='S';ans[n-1]='S';
FOR(i,1,n){
if(s[i]=='o'&&ans[i]=='S'||s[i]=='x'&&ans[i]=='W'){
if(i==n-1){
if(ans[0]==ans[i-1]){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i];
}
else{
if(i==n-1){
if(ans[0]==(ans[i-1]=='S'?'W':'S')){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i]=='S'?'W':'S';
}
}
ans[1]='W';ans[n-1]='W';
FOR(i,1,n){
if(s[i]=='o'&&ans[i]=='S'||s[i]=='x'&&ans[i]=='W'){
if(i==n-1){
if(ans[0]==ans[i-1]){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i];
}
else{
if(i==n-1){
if(ans[0]==(ans[i-1]=='S'?'W':'S')){
cout<<ans<<endl;return 0;
}
}
else ans[i+1]=ans[i]=='S'?'W':'S';
}
}
}
cout<<-1<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:95:12: error: redeclaration of 'std::string ans'
95 | string ans(n,'W');
| ^~~
a.cc:14:12: note: 'std::string ans' previously declared here
14 | string ans(n,'S');
| ^~~
|
s146063568 | p03798 | C | #include <stdio.h>
#define MAXNUM 100001
char judge[MAXNUM] = {'\0'};
int animal[MAXNUM] = {-1};
void solve(char judge, int *animal);
int main(void)
{
int N = 0;
int i;
scanf("%d", &N);
scanf("%s", judge);
animal[0] = 0; //S:0, W:1
animal[N - 1] = 1;
for (i = 0; i < N; i++)
judge(i);
if (animal[0] == 0 && animal[N - 1] == 1)
{
for (i = 0; i < N; i++)
{
if (animal[i])
printf("W");
else
printf("S");
}
return 0;
}
animal[0] = 0; //S:0, W:1
animal[N - 1] = 0;
for (i = 0; i < N; i++)
judge(i);
if (animal[0] == 0 && animal[N - 1] == 0)
{
for (i = 0; i < N; i++)
{
if (animal[i])
printf("W");
else
printf("S");
}
return 0;
}
animal[0] = 1; //S:0, W:1
animal[N - 1] = 0;
for (i = 0; i < N; i++)
judge(i);
if (animal[0] == 1 && animal[N - 1] == 0)
{
for (i = 0; i < N; i++)
{
if (animal[i])
printf("W");
else
printf("S");
}
return 0;
}
animal[0] = 1; //S:0, W:1
animal[N - 1] = 1;
for (i = 0; i < N; i++)
judge(i);
if (animal[0] == 1 && animal[N - 1] == 1)
{
for (i = 0; i < N; i++)
{
if (animal[i])
printf("W");
else
printf("S");
}
return 0;
}
printf("-1");
return 0;
}
void judge(int i)
{
if (judge[i] == 'o')
{
if (i == 0)
{
if (animal[i])
animal[i + 1] = !animal[N - 1];
else
animal[i + 1] = animal[N - 1];
}
else if (i == N - 1)
{
if (animal[i])
animal[0] = !animal[N - 2];
else
animal[0] = animal[N - 2];
}
else
{
if (animal[i])
animal[i + 1] = !animal[i - 1];
else
animal[i + 1] = animal[i - 1];
}
}
else
{
if (i == 0)
{
if (animal[i])
animal[i + 1] = animal[N - 1];
else
animal[i + 1] = !animal[N - 1];
}
else if (i == N - 1)
{
if (animal[i])
animal[0] = animal[N - 2];
else
animal[0] = !animal[N - 2];
}
else
{
if (animal[i])
animal[i + 1] = animal[i - 1];
else
animal[i + 1] = !animal[i - 1];
}
}
} | main.c: In function 'main':
main.c:19:9: error: called object 'judge' is not a function or function pointer
19 | judge(i);
| ^~~~~
main.c:4:6: note: declared here
4 | char judge[MAXNUM] = {'\0'};
| ^~~~~
main.c:35:9: error: called object 'judge' is not a function or function pointer
35 | judge(i);
| ^~~~~
main.c:4:6: note: declared here
4 | char judge[MAXNUM] = {'\0'};
| ^~~~~
main.c:51:9: error: called object 'judge' is not a function or function pointer
51 | judge(i);
| ^~~~~
main.c:4:6: note: declared here
4 | char judge[MAXNUM] = {'\0'};
| ^~~~~
main.c:67:9: error: called object 'judge' is not a function or function pointer
67 | judge(i);
| ^~~~~
main.c:4:6: note: declared here
4 | char judge[MAXNUM] = {'\0'};
| ^~~~~
main.c: At top level:
main.c:84:6: error: 'judge' redeclared as different kind of symbol
84 | void judge(int i)
| ^~~~~
main.c:4:6: note: previous definition of 'judge' with type 'char[100001]'
4 | char judge[MAXNUM] = {'\0'};
| ^~~~~
main.c: In function 'judge':
main.c:86:14: error: subscripted value is neither array nor pointer nor vector
86 | if (judge[i] == 'o')
| ^
main.c:91:41: error: 'N' undeclared (first use in this function)
91 | animal[i + 1] = !animal[N - 1];
| ^
main.c:91:41: note: each undeclared identifier is reported only once for each function it appears in
|
s434217616 | p03798 | C++ | #include<iostream>
using namespace std;
int main(){
int n;
string _s;
cin>>n>>_s;
bool s[100200] = {};
for(int i = 0;i < n;i++)s[i] = _s[i] == 'o' ? 0 : 1;
bool b[100200] = {};
for(int q = 0;q < 3;q++){
b[0] = q&1;
b[1] = q&2;
for(int i = 2;i < n;i++){
b[i] = b[i-2] ^ s[i-1];
}
if(b[n-1] == b[1] ^ s[0]){
for(int j = 0;j < n;j++){
cout << s[j] == 0 ? 'S' : 'W';
cout << endl;
}
return 0;
}
}
cout << -1 << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:19:18: error: no match for 'operator==' (operand types are 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} and 'int')
19 | cout << s[j] == 0 ? 'S' : 'W';
| ~~~~~~~~~~~~ ^~ ~
| | |
| | int
| std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}
a.cc:19:18: note: candidate: 'operator==(int, int)' (built-in)
19 | cout << s[j] == 0 ? 'S' : 'W';
| ~~~~~~~~~~~~~^~~~
a.cc:19:18: note: no known conversion for argument 1 from 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} to 'int'
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::fpos<_StateT>'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::allocator<_CharT>'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::pair<_T1, _T2>'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3819 | operator==(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: mismatched types 'const _CharT*' and 'std::basic_ostream<char>'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2558 | operator==(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed:
a.cc:19:21: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::tuple<_UTypes ...>'
19 | cout << s[j] == 0 ? 'S' : 'W';
| ^
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46:
/usr/include/c++/14/bits/streambuf_iterator.h:234:5: |
s952583642 | p03798 | C++ | #include<iostream>
using namespace std;
int main(){
int n;
string _s;
cin>>n>>_s;
bool s[100200] = {};
for(int i = 0;i < n;i++)s[i] = _s[i] == 'o' ? 0 : 1;
bool b[100200] = {};
for(int q = 0;q < 3;q++){
b[0] = q&1;
b[1] = q&2;
for(int i = 2;i < n;i++){
b[i] = b[i-2] ^ s[i-1];
}
if(b[n-1] == b[1] ^ s[0]){
for(int j = 0;j < n;j++){
cout << s[i] == 0 ? 'o' : 'x';
cout << endl;
}
return 0;
}
}
cout << -1 << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:19:11: error: 'i' was not declared in this scope
19 | cout << s[i] == 0 ? 'o' : 'x';
| ^
|
s806506989 | p03798 | C++ | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
char *search(char a, char b, char *s, int N) {
char *ans = (char *)malloc(N + 1);
ans[0] = a;
ans[1] = b;
for (int i = 0; i < N - 1; i++) {
if (s[i + 1] == 'o' && ans[i + 1] == 'S') {
ans[i + 2] = ans[i];
} else if (s[i + 1] == 'x' && ans[i + 1] == 'W') {
ans[i + 2] = ans[i];
} else {
if (ans[i] == 'S') {
ans[i + 2] = 'W';
} else {
ans[i + 2] = 'S';
}
}
}
if (ans[0] == ans[N]) {
ans[N] = '\0';
return ans;
} else {
return NULL;
}
}
int main() {
int N;
char *s = (char *)malloc(N + 1);
cin >> N >> s;
// scanf("%d\n%s", &N, s);上と同じ意味
// cout << search('S', 'S', s, N) << endl;
char *epoch0 = search('S', 'S', s, N);
//char *epoch1 = search('S', 'W', s, N);
//char *epoch2 = search('W', 'S', s, N);
//char *epoch3 = search('W', 'W', s, N);
/*
if (epoch0 == NULL && epoch1 == NULL && epoch2 == NULL && epoch3 == NULL) {
cout << -1 << endl;
} else {
cout << epoch0 << epoch1 << epoch2 << epoch3 << endl;
}
*/
if (epoch0 != NULL) {
cout << epoch0 << endl;
} else if (epoch1 != NULL) {
cout << epoch1 << endl;
} else if (epoch2 != NULL) {
cout << epoch1 << endl;
} else if (epoch3 != NULL) {
cout << epoch3 << endl;
} else {
cout << -1 << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:53:14: error: 'epoch1' was not declared in this scope; did you mean 'epoch0'?
53 | } else if (epoch1 != NULL) {
| ^~~~~~
| epoch0
a.cc:55:14: error: 'epoch2' was not declared in this scope; did you mean 'epoch0'?
55 | } else if (epoch2 != NULL) {
| ^~~~~~
| epoch0
a.cc:57:14: error: 'epoch3' was not declared in this scope; did you mean 'epoch0'?
57 | } else if (epoch3 != NULL) {
| ^~~~~~
| epoch0
|
s727785432 | p03798 | C++ | #include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define sc scanf
#define pr printf
using namespace std;
typedef long long ll;
const int N = 100000+100;
bool ans[N];
char str[N];
bool hander_ans(int n);
bool is_right(int check_index , int rh , int lh);
int main()
{
int i,j,n;
while(~sc("%d",&n))
{
sc(" %s",str);
ans[0] = 0 , ans[1] = 0;
if(hander_ans(n)) continue;
ans[0] = 0 , ans[1] = 1;
if(hander_ans(n)) continue;
ans[0] = 1 , ans[1] = 0;
if(hander_ans(n)) continue;
ans[0] = 1 , ans[1] = 1;
if(hander_ans(n)) continue;
pr("-1\n");
}
return 0;
}
bool is_right(int check_index , int rh , int lh)
{
if(ans[check_index] == 0)
{
if(str[check_index] == 'o' ) return ans[rh] == ans[lh];
if(str[check_index] == 'x' ) return ans[rh] != ans[lh];
}
else
{
if(str[check_index] == 'o' ) return ans[rh] != ans[lh];
if(str[check_index] == 'x' ) return ans[rh] == ans[lh];
}
return 0;
}
bool hander_ans(int n)
{
int i,j,flag = 0;
for(i=2; i<n; i++)
{
if(ans[i-1] == 0)
{
if(str[i-1] == 'o')
ans[i] = ans[i-2];
else
ans[i] = !ans[i-2];
}
else
{
if(str[i-1] == 'o')
ans[i] = !ans[i-2];
else
ans[i] = ans[i-2];
}
}
if((is_right(n-1,0,n-2) && is_right(0,1,n-1))
{
for(i=0; i<n; i++)
{
if(ans[i])
pr("W");
else
pr("S");
}
pr("\n");
return 1;
}
return 0;
}
| a.cc: In function 'bool hander_ans(int)':
a.cc:76:50: error: expected ';' before '{' token
76 | if((is_right(n-1,0,n-2) && is_right(0,1,n-1))
| ^
| ;
77 | {
| ~
a.cc:88:5: error: expected primary-expression before 'return'
88 | return 0;
| ^~~~~~
a.cc:87:6: error: expected ')' before 'return'
87 | }
| ^
| )
88 | return 0;
| ~~~~~~
a.cc:76:7: note: to match this '('
76 | if((is_right(n-1,0,n-2) && is_right(0,1,n-1))
| ^
a.cc:89:1: warning: no return statement in function returning non-void [-Wreturn-type]
89 | }
| ^
|
s321530346 | p03798 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll query(int left, int now, char c) {
if(now == 0) {
return (c == 'o') ? left : (left+1) % 2;
}
return (c == 'x') ? left : (left+1) % 2;
}
int arr[100001];
const int dir[4] = {{0,0},{0,1},{1,0},{1,1}};
string solve(ll n, string s) {
for(int x=0; x<4;x++) {
for(int i=0; i< n; i++) {
arr[i] = -1;
}
arr[0] = dir[x][0];
arr[1] = dir[x][1];
for(int i = 2; i < n; ++i) {
arr[i] = query(arr[i-2], arr[i-1], s[i-1]);
}
// check
if(arr[0] == query(arr[n-2], arr[n-1], s[n-1])) {
string ret="";
for(int i=0;i<n;++i) {
ret += (arr[i]==0)? "S" : "W";
}
return ret;
}
}
return "-1";
}
int main() {
ll n;
string s;
cin >> n >> s;
cout<< solve(n, s)<<endl;
}
| a.cc:13:44: error: cannot convert '<brace-enclosed initializer list>' to 'const int' in initialization
13 | const int dir[4] = {{0,0},{0,1},{1,0},{1,1}};
| ^
a.cc:13:44: error: cannot convert '<brace-enclosed initializer list>' to 'const int' in initialization
a.cc:13:44: error: cannot convert '<brace-enclosed initializer list>' to 'const int' in initialization
a.cc:13:44: error: cannot convert '<brace-enclosed initializer list>' to 'const int' in initialization
a.cc: In function 'std::string solve(ll, std::string)':
a.cc:20:20: error: invalid types 'const int[int]' for array subscript
20 | arr[0] = dir[x][0];
| ^
a.cc:21:20: error: invalid types 'const int[int]' for array subscript
21 | arr[1] = dir[x][1];
| ^
|
s446155249 | p03798 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define REP(i,m,n) for (int i=m;i<n;i++)
#define FOR(i,m,n,a) for(int i=m;i<n;i+=a)
const ll MOD=1e9+7;
int n;
int MAX=100000;
char p[MAX+2];
bool ans[MAX+2];
bool solve(){
REP(i,2,(n+2)+1){
if(p[i-1]=='o'){
ans[i]=(ans[i-1])?ans[i-2]:(!ans[i-2]);
}
else{
ans[i]=(ans[i-1])?(!ans[i-2]):ans[i-2];
}
}
if(ans[0]==ans[n]&&ans[1]==ans[n+1]){
REP(i,0,n){
cout << (ans[i]?'S':'W');
}
cout << endl;
return true;
}
return false;
}
int main(){
cin >> n >> p;
p[n]=p[0];p[n+1]=p[1];
bool PAT[4][2]={{true,true},{true,false},{false,true},{false,false}};
REP(i,0,4){
ans[0]=PAT[i][0];
ans[1]=PAT[i][1];
if(solve()){
return 0;
}
}
cout << "-1" << endl;
return 0;
}
| a.cc:10:11: error: size of array 'p' is not an integral constant-expression
10 | char p[MAX+2];
| ~~~^~
a.cc:11:13: error: size of array 'ans' is not an integral constant-expression
11 | bool ans[MAX+2];
| ~~~^~
|
s911467612 | p03798 | C | #include <stdio.h>
int main()
{
int N;
char S[100001];
int syu[100001];
int i;
scanf("%d", &N);
scanf("%s", &S);
// 1 = S
// -1 = W
while(k < 4) {
if(k == 0) {
syu[0] = 1;
syu[1] = 1;
} else if(k == 1) {
syu[0] = 1;
syu[1] = -1;
} else if(k == 2) {
syu[0] = -1;
syu[1] = 1;
} else if(k == 3) {
syu[0] = -1;
syu[1] = -1;
}
for(i = 1; i < N; i++) {
if(syu[i] == 1) {
if(S[i] == 'o') {
syu[i+1] = syu[i-1];
} else { //S[i] == 'x'
syu[i+1] = -syu[i-1];
}
} else { //syu[i] == -1
if(S[i] == 'o') {
syu[i+1] = -syu[i-1];
} else { //S[i] == 'x'
syu[i+1] = syu[i-1];
}
}
}
if(syu[0] != syu[N]) {
k++;
} else {
for(i = 0; i < N; i++) {
if(syu[i] == 1) {
printf("S");
} else {
printf("W");
}
}
printf("\n");
return 0;
}
}
printf("%d\n", -1);
return 0;
} | main.c: In function 'main':
main.c:15:9: error: 'k' undeclared (first use in this function)
15 | while(k < 4) {
| ^
main.c:15:9: note: each undeclared identifier is reported only once for each function it appears in
|
s362676746 | p03798 | C++ | #include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;
char check[4][100010];
int main()
{
int N;
string s;
cin >> N >> s;
check[0][0] = check[1][0] = 'S'; // s[0] が S の場合
check[2][0] = check[3][0] = 'W'; // s[0] が W の場合
if(s[0] == 'o')
{
check[0][1] = check[0][s.size()-1] = 'S'; // 両隣が S
check[1][1] = check[1][s.size()-1] = 'W'; // 両隣が W
check[2][1] = check[3][s.size()-1] = 'S'; // 2 は右が S 左が W
check[3][1] = check[2][s.size()-1] = 'W'; // 3 は右が W 左が S
} else {
check[0][1] = check[1][s.size()-1] = 'S'; // 0 は右が S 左が W
check[1][1] = check[0][s.size()-1] = 'W'; // 1 は右が W 左が S
check[2][1] = check[2][s.size()-1] = 'S'; // 両隣が S
check[3][1] = check[3][s.size()-1] = 'W'; // 両隣が W
}
int i;
for(i=1; i<s.size()-2; ++i) {
REP(j, 4) {
if(s[i] == 'o') {
if(check[j][i] == 'S') { check[j][i+1] = check[j][i-1]; }
else if(check[j][i] == 'W'){ check[j][i+1] = (check[j][i-1]=='S') ? 'W' : 'S'; }
} else {
if(check[j][i] == 'W') { check[j][i+1] = check[j][i-1]; }
else if(check[j][i] == 'S'){ check[j][i+1] = (check[j][i-1]=='S') ? 'W' : 'S'; }
}
}
}
int isExist = -1;
REP(j,4) {
if(s[i] == 'o') {
if(check[j][i] == 'S' && check[j][i+1] == check[j][i-1])
{
if(s[i+1] == 'o') {
if(check[j][i+1] == 'S' && check[j][i] == check[j][0]) { isExist = j; break; }
else if(check[j][i+1] == 'W' && check[j][i] != check[j][0]) { isExitst = j; break; }
} else {
if(check[j][i+1] == 'W' && check[j][i] == check[j][0]) { isExist = j; break; }
else if(check[j][i+1] == 'S' && check[j][i] != check[j][0]) { isExitst = j; break; }
}
}
else if(check[j][i] == 'W' && check[j][i+1] != check[j][i-1])
{
if(s[i+1] == 'o') {
if(check[j][i+1] == 'S' && check[j][i] == check[j][0]) { isExist = j; break; }
else if(check[j][i+1] == 'W' && check[j][i] != check[j][0]) { isExitst = j; break; }
} else {
if(check[j][i+1] == 'W' && check[j][i] == check[j][0]) { isExist = j; break; }
else if(check[j][i+1] == 'S' && check[j][i] != check[j][0]) { isExitst = j; break; }
}
}
} else {
if(check[j][i] == 'W' && check[j][i+1] == check[j][i-1])
{
if(s[i+1] == 'o') {
if(check[j][i+1] == 'S' && check[j][i] == check[j][0]) { isExist = j; break; }
else if(check[j][i+1] == 'W' && check[j][i] != check[j][0]) { isExitst = j; break; }
} else {
if(check[j][i+1] == 'W' && check[j][i] == check[j][0]) { isExist = j; break; }
else if(check[j][i+1] == 'S' && check[j][i] != check[j][0]) { isExitst = j; break; }
}
}
else if(check[j][i] == 'S' && check[j][i+1] != check[j][i-1])
{
if(s[i+1] == 'o') {
if(check[j][i+1] == 'S' && check[j][i] == check[j][0]) { isExist = j; break; }
else if(check[j][i+1] == 'W' && check[j][i] != check[j][0]) { isExitst = j; break; }
} else {
if(check[j][i+1] == 'W' && check[j][i] == check[j][0]) { isExist = j; break; }
else if(check[j][i+1] == 'S' && check[j][i] != check[j][0]) { isExitst = j; break; }
}
}
}
}
if(isExist < 0){ printf("-1\n"); return 0; }
REP(j, s.size()) { printf("%c", check[isExist][j]); }
printf("\n");
return 0;
}
| a.cc: In function 'int main()':
a.cc:64:83: error: 'isExitst' was not declared in this scope; did you mean 'isExist'?
64 | else if(check[j][i+1] == 'W' && check[j][i] != check[j][0]) { isExitst = j; break; }
| ^~~~~~~~
| isExist
a.cc:67:83: error: 'isExitst' was not declared in this scope; did you mean 'isExist'?
67 | else if(check[j][i+1] == 'S' && check[j][i] != check[j][0]) { isExitst = j; break; }
| ^~~~~~~~
| isExist
a.cc:74:83: error: 'isExitst' was not declared in this scope; did you mean 'isExist'?
74 | else if(check[j][i+1] == 'W' && check[j][i] != check[j][0]) { isExitst = j; break; }
| ^~~~~~~~
| isExist
a.cc:77:83: error: 'isExitst' was not declared in this scope; did you mean 'isExist'?
77 | else if(check[j][i+1] == 'S' && check[j][i] != check[j][0]) { isExitst = j; break; }
| ^~~~~~~~
| isExist
a.cc:85:83: error: 'isExitst' was not declared in this scope; did you mean 'isExist'?
85 | else if(check[j][i+1] == 'W' && check[j][i] != check[j][0]) { isExitst = j; break; }
| ^~~~~~~~
| isExist
a.cc:88:83: error: 'isExitst' was not declared in this scope; did you mean 'isExist'?
88 | else if(check[j][i+1] == 'S' && check[j][i] != check[j][0]) { isExitst = j; break; }
| ^~~~~~~~
| isExist
a.cc:95:83: error: 'isExitst' was not declared in this scope; did you mean 'isExist'?
95 | else if(check[j][i+1] == 'W' && check[j][i] != check[j][0]) { isExitst = j; break; }
| ^~~~~~~~
| isExist
a.cc:98:83: error: 'isExitst' was not declared in this scope; did you mean 'isExist'?
98 | else if(check[j][i+1] == 'S' && check[j][i] != check[j][0]) { isExitst = j; break; }
| ^~~~~~~~
| isExist
|
s266155328 | p03798 | C++ | #include "stdafx.h"
#include <stdio.h>
int main () {
long long int N,i;
int a[10000],b[10000],c,j,k;
scanf("%lld", &N);
char S[10000],T[10000];
scanf("%s", S);
for(i=0;i<N;i++){
if (S[i]=='o') a[i]=1;
if (S[i]=='x') a[i]=-1;
}
for(j=-1;j<=1;j=j+2){
for(k=-1;k<=1;k=k+2){
b[0]=j, b[1]=k;
for(i=0;i<N-2;i++){
if(b[i+1]*a[i+1]==1) b[i+2]=b[i];
if(b[i+1]*a[i+1]==-1) b[i+2]=-b[i];
}
if(a[N-1]*b[N-1]==b[N-2]*b[0] && a[0]*b[0]==b[N-1]*b[1]) {
for(i=0;i<N;i++){
if(b[i]==1) T[i]='S';
if(b[i]==-1) T[i]='W';
}
for(i=0;i<N;i++){
printf("%c",T[i]);
}
printf("\n");
return 0;
}
}
}
printf("-1\n");
return 0;
} | a.cc:1:10: fatal error: stdafx.h: No such file or directory
1 | #include "stdafx.h"
| ^~~~~~~~~~
compilation terminated.
|
s470499517 | p03798 | C | #include <stdio.h>
int main () {
long long int N,i;
int a[10000],b[10000],c,j,k;
scanf("%lld", &N);
char S[N-1],T[N-1];
scanf("%s", S);
for(i=0;i<N;i++){
if (S[i]=='o') a[i]=1;
if (S[i]=='x') a[i]=-1;
}
for(j=-1;j<=1;j=j+2){
for(k=-1;k<=1;k=k+2){
b[0]=j, b[1]=k;
for(i=0;i<N-2;i++){
if(b[i+1]*a[i+1]==1) b[i+2]=b[i];
if(b[i+1]*a[i+1]==-1) b[i+2]=-b[i];
}
if(a[N-1]*b[N-1]==b[N-2]*b[0] && a[0]*b[0]==b[N-1]*b[1]) {
for(i=0;i<N;i++){
if(b[i]==1) T[i]='S';
if(b[i]==-1) T[i]='W';
}
printf("%s\n",T);
return 0;
}
}
}
printf("-1\n");
return 0;
} | main.c: In function 'main':
main.c:12:1: error: stray '\302' in program
12 | <U+00A0>
| ^~~~~~~~
|
s344395879 | p03798 | C | #include <stdio.h>
int main () {
long long int N,i;
int a[10001],b[10001],c,j,k;
scanf("%lld", &N);
char S[N+1],T[N+1];
scanf("%s", S);
for(i=1;i<=N;i++){
if (S[i-1]=='o') a[i]=1;
if (S[i-1]=='x') a[i]=-1;
}
for(j=-1;j<=1;j=j+2){
for(k=-1;k<=1;k=k+2){
b[1]=j, b[2]=k;
for(i=1;i<=N-2;i++){
if(b[i+1]*a[i+1]==1) b[i+2]=b[i];
if(b[i+1]*a[i+1]==-1) b[i+2]=-b[i];
}
if(a[N]*b[N]==b[N-1]*b[1] && a[1]*b[1]==b[N]*b[2]) {
for(i=1;i<=N;i++){
if(b[i]==1) T[i-1]='S';
if(b[i]==-1) T[i-1]='W';
}
printf("%s\n",T);
return 0;
}
}
}
printf("-1\n");
return 0;
} | main.c: In function 'main':
main.c:12:1: error: stray '\302' in program
12 | <U+00A0>
| ^~~~~~~~
|
s431039497 | p03798 | C | #include<stdio.h>
#define S 100003
int N;
char list[S];
char s[S];
char getInv(char c){
if( c == 'S' ){
return 'W';
}
return 'S';
}
void output(){
int i;
for( i = 1; i <= N; i++ ){ printf("%c", list[i]); }
printf("\n");
return;
}
/*
void say(){
int r, i;
const char Sans[2] = {'x', 'o'};
const char Wans[2] = {'o', 'x'};
list[0] = list[N];
list[N+1] = list[1];
for( i = 1; i <= N; i++ ){
if( list[i-1] == list[i+1] ){
r = 1;
}else{
r = 0;
}
if( list[i] == 'S' ){
printf("%c", Sans[r]);
}else{
printf("%c", Wans[r]);
}
}
printf("\n");
return;
}
*/
int get(int i){
int re = 0;
if( i > N+1 ){
if( list[1] == list[N+1] && list[2] == list[N+2] ){
output();
return 1;
}
}else if( i == 1 ){
list[i+1] = 'S';
re = get(i+1);
if( re ){ return 1; }
list[i+1] = 'W';
re = get(i+1);
if( re ){ return 1; }
}else{
if( list[i] == 'S' && s[i] == 'o' ){
list[i+1] = list[i-1];
}
if( list[i] == 'S' && s[i] == 'x' ){
list[i+1] = getInv(list[i-1]);
}
if( list[i] == 'W' && s[i] == 'o' ){
list[i+1] = getInv(list[i-1]);
}
if( list[i] == 'W' && s[i] == 'x' ){
list[i+1] = list[i-1];
}
re = get(i+1);
}
return re;
}
int main(){
int i;
scanf("%d\n", &N);
for( i = 1; i <= N; i++ ){
scanf("%c", &s[i]);
}
s[N+1] = S[1];
list[1] = 'S';
if( get(1) ){ return 0; }
list[1] = 'W';
if( get(1) ){ return 0; }
printf("-1\n");
return 0;
}
| main.c: In function 'main':
main.c:85:19: error: subscripted value is neither array nor pointer nor vector
85 | s[N+1] = S[1];
| ^
|
s003670663 | p03798 | C | #include <stdio.h>
int main () {
int N,a[10000],b[10000],i;
scanf("%d", &N);
char S[N+1],T[N+1];
scanf("%s", S);
for(i=1;i<=N;i++){
if (S[i-1]=='o') a[i]=1;
if (S[i-1]=='x') a[i]=-1;
}
b[1]=1, b[2]=1;
for(i=1;i<=N-2;i++){
if(b[i+1]*a[i+1]==1) b[i+2]=b[i];
if(b[i+1]*a[i+1]==-1) b[i+2]=-b[i];
}
if(a[N]*b[N]==b[N-1]*b[1] && a[1]*b[1]==b[N]*b[2]) {
for(i=1;i<=N;i++){
if(b[i]==1) T[i-1]='S';
if(b[i]==-1) T[i-1]='W';
}
printf("%s\n",T);
return 0;
}
b[1]=1, b[2]=-1;
for(i=1;i<=N-2;i++){
if(b[i+1]*a[i+1]==1) b[i+2]=b[i];
if(b[i+1]*a[i+1]==-1) b[i+2]=-b[i];
}
if(a[N]*b[N]==b[N-1]*b[1] && a[1]*b[1]==b[N]*b[2]) {
for(i=1;i<=N;i++){
if(b[i]==1) T[i-1]='S';
if(b[i]==-1) T[i-1]='W';
}
printf("%s\n",T);
return 0;
}
b[1]=-1, b[2]=1;
for(i=1;i<=N-2;i++){
if(b[i+1]*a[i+1]==1) b[i+2]=b[i];
if(b[i+1]*a[i+1]==-1) b[i+2]=-b[i];
}
if(a[N]*b[N]==b[N-1]*b[1] && a[1]*b[1]==b[N]*b[2]) {
for(i=1;i<=N;i++){
if(b[i]==1) T[i-1]='S';
if(b[i]==-1) T[i-1]='W';
}
printf("%s\n",T);
return 0;
}
b[1]=-1, b[2]=-1;
for(i=1;i<=N-2;i++){
if(b[i+1]*a[i+1]==1) b[i+2]=b[i];
if(b[i+1]*a[i+1]==-1) b[i+2]=-b[i];
}
if(a[N]*b[N]==b[N-1]*b[1] && a[1]*b[1]==b[N]*b[2]) {
for(i=1;i<=N;i++){
if(b[i]==1) T[i-1]='S';
if(b[i]==-1) T[i-1]='W';
}
printf("%s\n",T);
return 0;
}
printf("%d\n",c-1);
return 0;
} | main.c: In function 'main':
main.c:11:1: error: stray '\302' in program
11 | <U+00A0>
| ^~~~~~~~
main.c:25:1: error: stray '\302' in program
25 | <U+00A0>
| ^~~~~~~~
main.c:39:1: error: stray '\302' in program
39 | <U+00A0>
| ^~~~~~~~
main.c:53:1: error: stray '\302' in program
53 | <U+00A0>
| ^~~~~~~~
main.c:67:15: error: 'c' undeclared (first use in this function)
67 | printf("%d\n",c-1);
| ^
main.c:67:15: note: each undeclared identifier is reported only once for each function it appears in
|
s420448354 | p03798 | C | #include <stdio.h>
int main () {
int N,a[10000],b[10000],i;
scanf("%d", &N);
char S[N+1],T[N+1];
scanf("%s", S);
for(i=1;i<=N;i++){
if (S[i-1]=='o') a[i]=1;
if (S[i-1]=='x') a[i]=-1;
}
b[1]=1, b[2]=1;
for(i=1;i<=N-2;i++){
if(b[i+1]*a[i+1]==1) b[i+2]=b[i];
if(b[i+1]*a[i+1]==-1) b[i+2]=-b[i];
}
if(a[N]*b[N]==b[N-1]*b[1] && a[1]*b[1]==b[N]*b[2]) {
for(i=1;i<=N;i++){
if(b[i]==1) T[i-1]='S';
if(b[i]==-1) T[i-1]='W';
}
printf("%s\n",T);
return 0;
}
b[1]=1, b[2]=-1;
for(i=1;i<=N-2;i++){
if(b[i+1]*a[i+1]==1) b[i+2]=b[i];
if(b[i+1]*a[i+1]==-1) b[i+2]=-b[i];
}
if(a[N]*b[N]==b[N-1]*b[1] && a[1]*b[1]==b[N]*b[2]&&c==0) {
for(i=1;i<=N;i++){
if(b[i]==1) T[i-1]='S';
if(b[i]==-1) T[i-1]='W';
}
printf("%s\n",T);
return 0;
}
b[1]=-1, b[2]=1;
for(i=1;i<=N-2;i++){
if(b[i+1]*a[i+1]==1) b[i+2]=b[i];
if(b[i+1]*a[i+1]==-1) b[i+2]=-b[i];
}
if(a[N]*b[N]==b[N-1]*b[1] && a[1]*b[1]==b[N]*b[2]&&c==0) {
for(i=1;i<=N;i++){
if(b[i]==1) T[i-1]='S';
if(b[i]==-1) T[i-1]='W';
}
printf("%s\n",T);
return 0;
}
b[1]=-1, b[2]=-1;
for(i=1;i<=N-2;i++){
if(b[i+1]*a[i+1]==1) b[i+2]=b[i];
if(b[i+1]*a[i+1]==-1) b[i+2]=-b[i];
}
if(a[N]*b[N]==b[N-1]*b[1] && a[1]*b[1]==b[N]*b[2]&&c==0) {
for(i=1;i<=N;i++){
if(b[i]==1) T[i-1]='S';
if(b[i]==-1) T[i-1]='W';
}
printf("%s\n",T);
return 0;
}
printf("%d\n",c-1);
return 0;
} | main.c: In function 'main':
main.c:11:1: error: stray '\302' in program
11 | <U+00A0>
| ^~~~~~~~
main.c:25:1: error: stray '\302' in program
25 | <U+00A0>
| ^~~~~~~~
main.c:31:52: error: 'c' undeclared (first use in this function)
31 | if(a[N]*b[N]==b[N-1]*b[1] && a[1]*b[1]==b[N]*b[2]&&c==0) {
| ^
main.c:31:52: note: each undeclared identifier is reported only once for each function it appears in
main.c:39:1: error: stray '\302' in program
39 | <U+00A0>
| ^~~~~~~~
main.c:53:1: error: stray '\302' in program
53 | <U+00A0>
| ^~~~~~~~
|
s970094241 | p03798 | C++ | #include <iostream>
#include <string>
using namespace std;
int mod = 1000000007;
bool ii[100000],oo[100000];
void p(){
string str;
for(int i = 0;i < N;i++){
if(oo[i]) str += 'S';
else str += 'W';
}
cout << str;
}
int main() {
// your code goes here
int N;
string in,out;
cin >> N;
cin >> in;
for(int i = 0;i < N;i++){
ii[i] = (in[i] == 'o');
}
oo[0] = true;
oo[1] = true;
for(int i = 2;i < N-2;i++){
oo[i] = (ii[i-1] != oo[i-2]);
}
if(oo[0] == (ii[N-1] != oo[N-2]) && (ii[0] != oo[N-1])){
p();
return 0;
}
oo[0] = false;
oo[1] = true;
for(int i = 2;i < N-2;i++){
oo[i] = (ii[i-1] != oo[i-2]);
}
if(oo[0] == (ii[N-1] != oo[N-2]) && (ii[0] != oo[N-1])){
p();
return 0;
}
oo[0] = true;
oo[1] = false;
for(int i = 2;i < N-2;i++){
oo[i] = (ii[i-1] != oo[i-2]);
}
if(oo[0] == (ii[N-1] != oo[N-2]) && (ii[0] != oo[N-1])){
p();
return 0;
}
oo[0] = false;
oo[1] = false;
for(int i = 2;i < N-2;i++){
oo[i] = (ii[i-1] != oo[i-2]);
}
if(oo[0] == (ii[N-1] != oo[N-2]) && (ii[0] != oo[N-1])){
p();
return 0;
}
cout << -1 << endl;
return 0;
} | a.cc: In function 'void p()':
a.cc:10:27: error: 'N' was not declared in this scope
10 | for(int i = 0;i < N;i++){
| ^
|
s389239100 | p03798 | C++ | /* . ∧_∧
( ´・ω・)
//\ ̄ ̄旦\
// ※ \___\
\\ ※ ※ ※ ヽ
\ヽ-___--___ヽ*/
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define vvsort(v) sort(v.begin(),v.end(),greater<int>());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
typedef priority_queue<int> pq;
typedef priority_queue<int,vector<int>,greater<int> > rpq;
bool is_uruu(int y) {
return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//-------------------------------------------------------------------------------------------------------------------------------------------//
/*void dfs(string t,int m){
if(m==n){
cout<<
return ;
}
}*/
string a[100000];
string b[100000];
int main(){
int n;
string s;
cin>>n;
cin>>s;
}
cout<<-1<<endl;
} | a.cc:46:9: error: 'cout' does not name a type
46 | cout<<-1<<endl;
| ^~~~
a.cc:47:1: error: expected declaration before '}' token
47 | }
| ^
|
s277749132 | p03798 | C++ | #include <bits/stdc++.h>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
using namespace std;
int uni[1000010];
void init(int N){
for(int i=0;i<N;i++){
uni[i]=-1;
}
}
int root(int a){
if(uni[a] < 0)return a;
else return uni[a] = root(uni[a]);
}
bool unite(int a,int b){
a = root(a);
b = root(b);
if(a==b) return false;
if(uni[a] > uni[b]) swap(a,b);
uni[a]+=uni[b];
uni[b]=a;
}
bool same(int a,int b){
a = root(a);
b = root(b);
if(a==b)return true;
else return false;
}
int animal[100010];
void ch(){
for(int i=0;i<n-1;i++){
if(s[i]=='o' && animal[i]==1){
if(i-1<0){
unite(n-1,1);
animal[1]=1;
}else{
animal[i+1]=animal[i-1];
unite(i-1,i+1);
}
}
if(s[i]=='x' && animal[i]==1){
if(i-1<0){
animal[1]=2;
}else{
if(animal[i-1]==1)animal[i+1]=2;
if(animal[i-1]==2)animal[i+1]=1;
}
}
if(s[i]=='x' && animal[i]==2){
if(i-1<0){
unite(n-1,1);
}else{
animal[i+1]=animal[i-1];
unite(i-1,i+1);
}
}
if(s[i]=='o' && animal[i]==2){
if(i-1<0){
//
animal[1]=1;
}else{
if(animal[i-1]==1)animal[i+1]=2;
if(animal[i-1]==2)animal[i+1]=1;
}
}
}
}
int main(){
//最後と始めが羊だとする。
int n;
string s;
cin>>n;
cin>>s;
init(n);
//1羊 2狼
for(int i=0;i<n;i++)animal[i]=1;
ch();
int px=n-1;
bool flag=true;
if(s[px]=='o' && animal[px]==1){
if(!same(px-1,0))flag=false;
}
if(s[px]=='o' && animal[px]==2){
if(same(px-1,0))flag=false;
}
if(s[px]=='x' && animal[px]==1){
if(same(px-1,0))flag=false;
}
if(s[px]=='x' && animal[px]==2){
if(!same(px-1,0))flag=false;
}
if(!flag){
ch();
int px=n-1;
bool flag=true;
if(s[px]=='o' && animal[px]==1){
if(!same(px-1,0))flag=false;
}
if(s[px]=='o' && animal[px]==2){
if(same(px-1,0))flag=false;
}
if(s[px]=='x' && animal[px]==1){
if(same(px-1,0))flag=false;
}
if(s[px]=='x' && animal[px]==2){
if(!same(px-1,0))flag=false;
}
if(!flag)
cout<<"-1"<<endl;
else{
string ans="";
for(int i=0;i<n;i++){
if(animal[i]==1)ans+="S";
else ans+="W";
//cout<<"uni["<<i<<"]"<<uni[i]<<endl;
}
cout<<ans<<endl;
}
}else{
string ans="";
for(int i=0;i<n;i++){
if(animal[i]==1)ans+="S";
else ans+="W";
//cout<<"uni["<<i<<"]"<<uni[i]<<endl;
}
cout<<ans<<endl;
}
}
| a.cc: In function 'void ch()':
a.cc:40:17: error: 'n' was not declared in this scope
40 | for(int i=0;i<n-1;i++){
| ^
a.cc:41:8: error: 's' was not declared in this scope
41 | if(s[i]=='o' && animal[i]==1){
| ^
a.cc:51:8: error: 's' was not declared in this scope
51 | if(s[i]=='x' && animal[i]==1){
| ^
a.cc:60:8: error: 's' was not declared in this scope
60 | if(s[i]=='x' && animal[i]==2){
| ^
a.cc:68:8: error: 's' was not declared in this scope
68 | if(s[i]=='o' && animal[i]==2){
| ^
a.cc: In function 'bool unite(int, int)':
a.cc:26:9: warning: control reaches end of non-void function [-Wreturn-type]
26 | uni[b]=a;
| ~~~~~~^~
|
s031581406 | p03798 | C++ | #include<bits/stdc++.h>
using namespace std;
int main() {
int N;
string str;
cin >> N >> str;
bool nxor[N];
for (int i = 0; i < N; i++) {
nxor[i] = (str[i] == 'o');
}
int line[N];
line[0] = 0;
line[1] = 0;
for (int i = 2; i < N; i++) {
if (line[i-1] == 0) {
line[i] = (nxor[i-1] ? line[i-2] : ~line[i-2]);
}
else {
line[i] = (nxor[i-1] ? ~line[i-2] : line[i-2]);
}
}
bool c = true;
if (nxor[0] && line[N-1] != line[1]) {
c = false;
}
if (!nxor[0] && line[N-1] == line[1]) {
c = false;
}
if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
if (c) {
for(int i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
c = true;
line[0] = 0;
line[1] = -1;
for (int i = 2; i < N; i++) {
if (line[i-1] == 0) {
line[i] = (nxor[i-1] ? line[i-2] : ~line[i-2]);
}
else {
line[i] = (nxor[i-1] ? ~line[i-2] : line[i-2]);
}
}
if (nxor[0] && line[N-1] != line[1]) {
c = false;
}
if (!nxor[0] && line[N-1] == line[1]) {
c = false;
}
if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
if (c) {
for(int i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
c = true;
line[0] = -1;
line[1] = 0;
for (int i = 2; i < N; i++) {
if (line[i-1] == 0) {
line[i] = (nxor[i-1] ? line[i-2] : ~line[i-2]);
}
else {
line[i] = (nxor[i-1] ? ~line[i-2] : line[i-2]);
}
}
if (nxor[0] && line[N-1] == line[1]) {
c = false;
}
if (!nxor[0] && line[N-1] != line[1]) {
c = false;
}
if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
if (c) {
for(int i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
c = true;
line[0] = -1;
line[1] = -1;
for (int i = 2; i < N; i++) {
if (line[i-1] == 0) {
line[i] = (nxor[i-1] ? line[i-2] : ~line[i-2]);
}
else {
line[i] = (nxor[i-1] ? ~line[i-2] : line[i-2]);
}
}
if (nxor[0] && line[N-1] == line[1]) {
c = false;
}
if (!nxor[0] && line[N-1] != line[1]) {
c = false;
}
if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
if (c) {
for(int i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
c = true;
cout << -1 << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:33:14: error: expected ']' before '}' token
33 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
| ^
| ]
a.cc:33:14: error: expected ')' before '}' token
33 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
| ~ ^
| )
a.cc:33:14: error: expected primary-expression before '}' token
a.cc: At global scope:
a.cc:33:19: error: expected unqualified-id before '!' token
33 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
| ^
a.cc:36:1: error: expected unqualified-id before 'if'
36 | if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
| ^~
a.cc:39:1: error: expected unqualified-id before 'if'
39 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
| ^~
a.cc:39:13: error: expected declaration before '}' token
39 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
| ^
a.cc:39:18: error: expected unqualified-id before '!' token
39 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
| ^
a.cc:43:1: error: expected unqualified-id before 'if'
43 | if (c) {
| ^~
a.cc:50:1: error: 'c' does not name a type
50 | c = true;
| ^
a.cc:52:1: error: 'line' does not name a type
52 | line[0] = 0;
| ^~~~
a.cc:53:1: error: 'line' does not name a type
53 | line[1] = -1;
| ^~~~
a.cc:54:1: error: expected unqualified-id before 'for'
54 | for (int i = 2; i < N; i++) {
| ^~~
a.cc:54:17: error: 'i' does not name a type
54 | for (int i = 2; i < N; i++) {
| ^
a.cc:54:24: error: 'i' does not name a type
54 | for (int i = 2; i < N; i++) {
| ^
a.cc:62:1: error: expected unqualified-id before 'if'
62 | if (nxor[0] && line[N-1] != line[1]) {
| ^~
a.cc:65:1: error: expected unqualified-id before 'if'
65 | if (!nxor[0] && line[N-1] == line[1]) {
| ^~
a.cc:68:1: error: expected unqualified-id before 'if'
68 | if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
| ^~
a.cc:71:1: error: expected unqualified-id before 'if'
71 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
| ^~
a.cc:71:14: error: expected declaration before '}' token
71 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
| ^
a.cc:71:19: error: expected unqualified-id before '!' token
71 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
| ^
a.cc:74:1: error: expected unqualified-id before 'if'
74 | if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
| ^~
a.cc:77:1: error: expected unqualified-id before 'if'
77 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
| ^~
a.cc:77:13: error: expected declaration before '}' token
77 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
| ^
a.cc:77:18: error: expected unqualified-id before '!' token
77 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
| ^
a.cc:81:1: error: expected unqualified-id before 'if'
81 | if (c) {
| ^~
a.cc:88:1: error: 'c' does not name a type
88 | c = true;
| ^
a.cc:90:1: error: 'line' does not name a type
90 | line[0] = -1;
| ^~~~
a.cc:91:1: error: 'line' does not name a type
91 | line[1] = 0;
| ^~~~
a.cc:92:1: error: expected unqualified-id before 'for'
92 | for (int i = 2; i < N; i++) {
| ^~~
a.cc:92:17: error: 'i' does not name a type
92 | for (int i = 2; i < N; i++) {
| ^
a.cc:92:24: error: 'i' does not name a type
92 | for (int i = 2; i < N; i++) {
| ^
a.cc:101:1: error: expected unqualified-id before 'if'
101 | if (nxor[0] && line[N-1] == line[1]) {
| ^~
a.cc:104:1: error: expected unqualified-id before 'if'
104 | if (!nxor[0] && line[N-1] != line[1]) {
| ^~
a.cc:107:1: error: expected unqualified-id before 'if'
107 | if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
| ^~
a.cc:110:1: error: expected unqualified-id before 'if'
110 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
| ^~
a.cc:110:14: error: expected declaration before '}' token
110 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
| ^
a.cc:110:19: error: expected unqualified-id before '!' token
110 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
| ^
a.cc:113:1: error: expected unqualified-id before 'if'
113 | if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
| ^~
a.cc:116:1: error: expected unqualified-id before 'if'
116 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
| ^~
a.cc:116:13: error: expected declaration before '}' token
116 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
| ^
a.cc:116:18: error: expected unqualified-id before '!' token
116 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
| ^
a.cc:120:1: error: expected unqualified-id before 'if'
120 | if (c) {
| ^~
a.cc:127:1: error: 'c' does not name a type
127 | c = true;
| ^
a.cc:129:1: error: 'line' does not name a type
129 | line[0] = -1;
| ^~~~
a.cc:130:1: error: 'line' does not name a type
130 | line[1] = -1;
| ^~~~
a.cc:131:1: error: expected unqualified-id before 'for'
131 | for (int i = 2; i < N; i++) {
| ^~~
a.cc:131:17: error: 'i' does not name a type
131 | for (int i = 2; i < N; i++) {
| ^
a.cc:131:24: error: 'i' does not name a type
131 | for (int i = 2; i < N; i++) {
| ^
a.cc:140:1: error: expected unqualified-id before 'if'
140 | if (nxor[0] && line[N-1] == line[1]) {
| ^~
a.cc:143:1: error: expected unqualified-id before 'if'
143 | if (!nxor[0] && line[N-1] != line[1]) {
| ^~
a.cc:146:1: error: expected unqualified-id before 'if'
146 | if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
| ^~
a.cc:149:1: error: expected unqualified-id before 'if'
149 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
| ^~
a.cc:149:14: error: expected declaration before '}' token
149 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
| ^
a.cc:149:19: error: expected unqualified-id before '!' token
149 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
| ^
a.cc:152:1: error: expected unqualified-id before 'if'
152 | if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
| ^~
a.cc:155:1: error: expected unqualified-id before 'if'
155 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
| ^~
a.cc:155:13: error: expected declaration before '}' token
155 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
| ^
a.cc:155:18: error: expected unqualified-id before '!' token
155 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
| ^
a.cc:159:1: error: expected unqualified-id before 'if'
159 | if (c) {
| ^~
a.cc:166:1: error: 'c' does not name a type
166 | c = true;
| ^
a.cc:168:1: error: 'cout' does not name a type
168 | cout << -1 << endl;
| ^~~~
a.cc:169:1: error: expected unqualified-id before 'return'
169 | return 0;
| ^~~~~~
a.cc:171:1: error: expected declaration before '}' token
171 | }
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.