답안 #20871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20871 2017-02-28T16:23:16 Z gs14004 돌 옮기기 (GA7_stone) C++11
56 / 100
1500 ms 2928 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<lint, lint> pi;
const int mod = 1e9 + 7;

string s;
int l, n;

int main(){
	cin >> l >> n;
	for(int i=0; i<2*n; i++){
		char t[5];
		scanf("%*d %s",t);
		s.push_back(*t);
	}
	string t = s + s;
	for(auto &i : s) i = 'W' + 'B' - i;
	int ans = 1e9;
	for(int i=0; i<2*n; i++){
		if(t.substr(i, 2*n) == s) ans = min({ans, i, 2*n-i});
	}
	if(ans > 1e8){
		puts("-1");
		return 0;
	}
	cout << 1ll * ans * l;
}

Compilation message

stone.cpp: In function 'int main()':
stone.cpp:15:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%*d %s",t);
                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
8 Correct 0 ms 2020 KB Output is correct
9 Correct 0 ms 2020 KB Output is correct
10 Correct 0 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
8 Correct 0 ms 2020 KB Output is correct
9 Correct 0 ms 2020 KB Output is correct
10 Correct 0 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
8 Correct 0 ms 2020 KB Output is correct
9 Correct 0 ms 2020 KB Output is correct
10 Correct 0 ms 2020 KB Output is correct
11 Correct 0 ms 2020 KB Output is correct
12 Correct 0 ms 2020 KB Output is correct
13 Correct 0 ms 2020 KB Output is correct
14 Correct 0 ms 2020 KB Output is correct
15 Correct 0 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 3 ms 2020 KB Output is correct
4 Correct 3 ms 2020 KB Output is correct
5 Correct 3 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
8 Correct 3 ms 2020 KB Output is correct
9 Correct 6 ms 2020 KB Output is correct
10 Correct 6 ms 2020 KB Output is correct
11 Correct 6 ms 2020 KB Output is correct
12 Correct 6 ms 2020 KB Output is correct
13 Correct 3 ms 2020 KB Output is correct
14 Correct 6 ms 2020 KB Output is correct
15 Correct 6 ms 2020 KB Output is correct
16 Correct 3 ms 2020 KB Output is correct
17 Correct 3 ms 2020 KB Output is correct
18 Correct 3 ms 2020 KB Output is correct
19 Correct 3 ms 2020 KB Output is correct
20 Correct 3 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1500 ms 2928 KB Execution timed out
2 Halted 0 ms 0 KB -