답안 #6335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
6335 2014-06-28T08:38:43 Z jhs7jhs 돌 옮기기 (GA7_stone) C++
56 / 100
1500 ms 5384 KB
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

long long r;
int n;
char s[400010]={0},p[800020]={0};
long long x[400010]={0};
int main()
{
    int i;
    int first,last;
    char *temp;
    char t[2]={0};
    scanf("%lld%d",&r,&n);
    n *= 2;
    for(i=0;i<n;i++){
        scanf("%lld%s",&x[i],t);
        s[i] = t[0];
    }
    for(i=0;i<n;i++){
        if(s[i] == 'W') p[i] = 'B';
        else p[i] = 'W';
    }
    for(i=0;i<n;i++) p[i+n] = p[i];
    temp = strstr(p,s);
    if(temp == NULL){
        printf("-1\n");
        return 0;
    }
    first = (int)(temp - p);
    reverse(s,s+n);
    reverse(p,p+2*n);
    temp = strstr(p,s);
    last = (int)(temp-p);
    if(first<=last) printf("%lld\n",r*(long long)first);
    else printf("%lld\n",r*(long long)last);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5384 KB Output is correct
2 Correct 0 ms 5384 KB Output is correct
3 Correct 0 ms 5384 KB Output is correct
4 Correct 0 ms 5384 KB Output is correct
5 Correct 0 ms 5384 KB Output is correct
6 Correct 0 ms 5384 KB Output is correct
7 Correct 0 ms 5384 KB Output is correct
8 Correct 0 ms 5384 KB Output is correct
9 Correct 0 ms 5384 KB Output is correct
10 Correct 0 ms 5384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5384 KB Output is correct
2 Correct 0 ms 5384 KB Output is correct
3 Correct 0 ms 5384 KB Output is correct
4 Correct 0 ms 5384 KB Output is correct
5 Correct 0 ms 5384 KB Output is correct
6 Correct 0 ms 5384 KB Output is correct
7 Correct 0 ms 5384 KB Output is correct
8 Correct 0 ms 5384 KB Output is correct
9 Correct 0 ms 5384 KB Output is correct
10 Correct 0 ms 5384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5384 KB Output is correct
2 Correct 0 ms 5384 KB Output is correct
3 Correct 0 ms 5384 KB Output is correct
4 Correct 0 ms 5384 KB Output is correct
5 Correct 0 ms 5384 KB Output is correct
6 Correct 0 ms 5384 KB Output is correct
7 Correct 0 ms 5384 KB Output is correct
8 Correct 0 ms 5384 KB Output is correct
9 Correct 0 ms 5384 KB Output is correct
10 Correct 0 ms 5384 KB Output is correct
11 Correct 0 ms 5384 KB Output is correct
12 Correct 0 ms 5384 KB Output is correct
13 Correct 0 ms 5384 KB Output is correct
14 Correct 0 ms 5384 KB Output is correct
15 Correct 0 ms 5384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5384 KB Output is correct
2 Correct 0 ms 5384 KB Output is correct
3 Correct 0 ms 5384 KB Output is correct
4 Correct 0 ms 5384 KB Output is correct
5 Correct 0 ms 5384 KB Output is correct
6 Correct 0 ms 5384 KB Output is correct
7 Correct 0 ms 5384 KB Output is correct
8 Correct 0 ms 5384 KB Output is correct
9 Correct 0 ms 5384 KB Output is correct
10 Correct 0 ms 5384 KB Output is correct
11 Correct 0 ms 5384 KB Output is correct
12 Correct 0 ms 5384 KB Output is correct
13 Correct 0 ms 5384 KB Output is correct
14 Correct 0 ms 5384 KB Output is correct
15 Correct 0 ms 5384 KB Output is correct
16 Correct 0 ms 5384 KB Output is correct
17 Correct 0 ms 5384 KB Output is correct
18 Correct 0 ms 5384 KB Output is correct
19 Correct 0 ms 5384 KB Output is correct
20 Correct 0 ms 5384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 5384 KB Output is correct
2 Correct 44 ms 5384 KB Output is correct
3 Execution timed out 1500 ms 5384 KB Program timed out
4 Halted 0 ms 0 KB -