# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
6330 |
2014-06-28T08:01:43 Z |
jhs7jhs |
돌 옮기기 (GA7_stone) |
C++ |
|
92 ms |
3236 KB |
#include<stdio.h>
#include<string.h>
long long r;
int n;
char s[200010]={0},p[400020]={0};
long long x[200010]={0};
long long ans=-1;
long long dist(long long p,long long q){
if(p<q) return q-p;
else return r - (p-q);
}
int main()
{
int i;
int first,last;
//long long sum = 0;
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 = last = (int)(temp - p);
while(1){
temp = strstr(p+last+1,s);
if(temp == NULL) break;
last = temp - p;
}
//for(i=0;i<n;i++) sum += dist(x[i],x[(i+first)%n]);
ans = r*first;
if(ans > r*(n-last)) ans = r*(n-last);
printf("%lld\n",ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3236 KB |
Output is correct |
2 |
Correct |
0 ms |
3236 KB |
Output is correct |
3 |
Correct |
0 ms |
3236 KB |
Output is correct |
4 |
Correct |
0 ms |
3236 KB |
Output is correct |
5 |
Correct |
0 ms |
3236 KB |
Output is correct |
6 |
Correct |
0 ms |
3236 KB |
Output is correct |
7 |
Correct |
0 ms |
3236 KB |
Output is correct |
8 |
Correct |
0 ms |
3236 KB |
Output is correct |
9 |
Correct |
0 ms |
3236 KB |
Output is correct |
10 |
Correct |
0 ms |
3236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3236 KB |
Output is correct |
2 |
Correct |
0 ms |
3236 KB |
Output is correct |
3 |
Correct |
0 ms |
3236 KB |
Output is correct |
4 |
Correct |
0 ms |
3236 KB |
Output is correct |
5 |
Correct |
0 ms |
3236 KB |
Output is correct |
6 |
Correct |
0 ms |
3236 KB |
Output is correct |
7 |
Correct |
0 ms |
3236 KB |
Output is correct |
8 |
Correct |
0 ms |
3236 KB |
Output is correct |
9 |
Correct |
0 ms |
3236 KB |
Output is correct |
10 |
Correct |
0 ms |
3236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3236 KB |
Output is correct |
2 |
Correct |
0 ms |
3236 KB |
Output is correct |
3 |
Correct |
0 ms |
3236 KB |
Output is correct |
4 |
Correct |
0 ms |
3236 KB |
Output is correct |
5 |
Correct |
0 ms |
3236 KB |
Output is correct |
6 |
Correct |
0 ms |
3236 KB |
Output is correct |
7 |
Correct |
0 ms |
3236 KB |
Output is correct |
8 |
Correct |
0 ms |
3236 KB |
Output is correct |
9 |
Correct |
0 ms |
3236 KB |
Output is correct |
10 |
Correct |
0 ms |
3236 KB |
Output is correct |
11 |
Correct |
0 ms |
3236 KB |
Output is correct |
12 |
Correct |
0 ms |
3236 KB |
Output is correct |
13 |
Correct |
0 ms |
3236 KB |
Output is correct |
14 |
Correct |
0 ms |
3236 KB |
Output is correct |
15 |
Correct |
0 ms |
3236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3236 KB |
Output is correct |
2 |
Correct |
0 ms |
3236 KB |
Output is correct |
3 |
Correct |
0 ms |
3236 KB |
Output is correct |
4 |
Correct |
0 ms |
3236 KB |
Output is correct |
5 |
Correct |
0 ms |
3236 KB |
Output is correct |
6 |
Correct |
0 ms |
3236 KB |
Output is correct |
7 |
Correct |
0 ms |
3236 KB |
Output is correct |
8 |
Correct |
0 ms |
3236 KB |
Output is correct |
9 |
Correct |
12 ms |
3236 KB |
Output is correct |
10 |
Correct |
0 ms |
3236 KB |
Output is correct |
11 |
Correct |
4 ms |
3236 KB |
Output is correct |
12 |
Correct |
0 ms |
3236 KB |
Output is correct |
13 |
Correct |
0 ms |
3236 KB |
Output is correct |
14 |
Correct |
4 ms |
3236 KB |
Output is correct |
15 |
Correct |
0 ms |
3236 KB |
Output is correct |
16 |
Correct |
4 ms |
3236 KB |
Output is correct |
17 |
Correct |
0 ms |
3236 KB |
Output is correct |
18 |
Correct |
0 ms |
3236 KB |
Output is correct |
19 |
Correct |
0 ms |
3236 KB |
Output is correct |
20 |
Correct |
0 ms |
3236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
3236 KB |
Output is correct |
2 |
Runtime error |
48 ms |
3232 KB |
futex (syscall #202) was called by the program (disallowed syscall) |
3 |
Halted |
0 ms |
0 KB |
- |