# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
542157 | AJ00 | Miners (IOI07_miners) | C++14 | 1584 ms | 1684 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<int> vec1,vec2;
deque<int> temp;
int val[100000];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int t=1,n,cur=0,ans=0;
//cin >> t;
string str;
while (t--){
cin >> n;
cin >> str;
for (int i = 0; i < n; i++){
if (str[i] == 'M'){
val[i] = 0;
}
if (str[i] == 'F'){
val[i] = 1;
}
if (str[i] == 'B'){
val[i] = 2;
}
}
for (int l = 0; l < (1<<n); l++){
vec1.clear();
vec2.clear();
for (int j = 0; j < n; j++){
if (l & (1 << j)){
vec1.push_back(val[j]);
if (l == 19){
// cout << j << " ";
}
}
else {
vec2.push_back(val[j]);
}
}
// reverse(vec1.begin(),vec1.end());
/* if (l == 19){
cout << "\n";
for (int i = 0; i < vec1.size(); i++){
cout << vec1[i] << " ";
}
cout << "\n";
for (int i = 0; i < vec2.size(); i++){
cout << vec2[i] << " ";
}
}*/
temp.clear();
cur = 0;
if (!vec1.empty()){
cur = 1;
temp.push_back(vec1[0]);
if (vec1.size() >= 2){
cur += 1;
cur += (vec1[0] != vec1[1]);
temp.push_back(vec1[1]);
}
/* if (l==19){
cout << cur << "\n";
}*/
for (int i = 2; i < vec1.size(); i++){
if (vec1[i] == temp[0] == temp[1]){
cur += 1;
}
else if (vec1[i] == temp[0] || vec1[i] == temp[1] || temp[0] == temp[1]){
cur += 2;
}
else {
cur += 3;
}
// cout << temp[0] << temp[1] << temp[2] << " ";
temp.pop_front();
temp.push_back(vec1[i]);
}
}
temp.clear();
if (!vec2.empty()){
cur += 1;
temp.push_back(vec2[0]);
if (vec2.size() >= 2){
cur += 1;
cur += (vec2[0] != vec2[1]);
temp.push_back(vec2[1]);
}
/* if (l==19){
cout << cur << "\n";
}*/
for (int i = 2; i < vec2.size(); i++){
if (vec2[i] == temp[0] == temp[1]){
cur += 1;
}
else if (vec2[i] == temp[0] || vec2[i] == temp[1] || temp[0] == temp[1]){
cur += 2;
}
else {
cur += 3;
}
//cout << temp[0] << temp[1] << temp[2] << " ";
temp.pop_front();
temp.push_back(vec2[i]);
}
}
else {
cur += 0;
}
/* if (l == 19){
cout << cur << "\n";
}*/
// cout << l << " " << cur << "\n";
ans = max(ans,cur);
}
cout << ans << "\n";
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |