# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1053411 | Dennis_Jason | Miners (IOI07_miners) | C++14 | 134 ms | 1372 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define NMAX 100001
#define int long long
#define pb push_back
#define eb emplace_back
#define MOD 1000000007
#define nl '\n'
#define INF 1000000007
#define LLONG_MAX 9223372036854775807
#define pii pair<int,int>
#define tpl tuple<int,int,int,int>
//#pragma GCC optimize("O3")
using namespace std;
ifstream fin("aib.in");
ofstream fout("aib.out");
/*
*
*
----------------DEMONSTRATION-------------------
MBMFFB
mine1 mine2
MBF MFB
1+2+3=6 1+2+3=6
MBMFFB
---------------------END------------------------
*/
/*-------------Initialize------------*/
int n;
string s;
int v[NMAX];
int res=0;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
cin>>s;
v[0]=0;
for(int i=1;i<=n;++i)
{
if(s[i-1]=='M')
v[i]=1;
else if(s[i-1]=='F')
v[i]=2;
else
v[i]=3;
map<int,int>mp;
if(v[i])
mp[v[i]]++;
if(v[i-1])
mp[v[i-1]]++;
if(v[i-2])
mp[v[i-2]]++;
if(mp.size()==1)
res+=1;
else if(mp.size()==2)
res+=2;
else
res+=3;
}
if(n<=18)
{
int MSK=(1<<n);
for(int mask=0;mask<MSK;++mask)
{
vector<int>ind1;
vector<int>ind2;
int new_mask=((MSK-1)^mask);
int aux_msk=mask;
if(new_mask>aux_msk)
swap(new_mask,aux_msk);
for(int bit=0;bit<n;++bit)
{
if(aux_msk&(1<<bit))
{
ind1.pb(bit+1);
}
}
for(int bit=0;bit<n;++bit)
{
if(new_mask&(1<<bit))
{
ind2.pb(bit+1);
}
}
// if(mask==47119)
// {
// for(auto x:ind1)
// cout<<x<<" ";
// }
int aux=0;
for(int i=0;i<ind1.size();++i)
{
map<int,int>mp;
if(i>=0)
mp[v[ind1[i]]]++;
if(i-1>=0)
mp[v[ind1[i-1]]]++;
if(i-2>=0)
mp[v[ind1[i-2]]]++;
if(mp.size()==1)
aux+=1;
else if(mp.size()==2)
aux+=2;
else
aux+=3;
}
for(int i=0;i<ind2.size();++i)
{
map<int,int>mp;
if(i>=0)
mp[v[ind2[i]]]++;
if(i-1>=0)
mp[v[ind2[i-1]]]++;
if(i-2>=0)
mp[v[ind2[i-2]]]++;
if(mp.size()==1)
aux+=1;
else if(mp.size()==2)
aux+=2;
else
aux+=3;
}
res=max(res,aux);
}
cout<<res;
}
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... |