제출 #1053411

#제출 시각아이디문제언어결과실행 시간메모리
1053411Dennis_JasonMiners (IOI07_miners)C++14
27 / 100
134 ms1372 KiB
#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) 메시지

miners.cpp:9: warning: "LLONG_MAX" redefined
    9 | #define LLONG_MAX 9223372036854775807
      | 
In file included from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:195,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:34,
                 from /usr/include/c++/10/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:39,
                 from miners.cpp:1:
/usr/include/limits.h:135: note: this is the location of the previous definition
  135 | #  define LLONG_MAX __LONG_LONG_MAX__
      | 
miners.cpp: In function 'int main()':
miners.cpp:102:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  102 |            for(int i=0;i<ind1.size();++i)
      |                        ~^~~~~~~~~~~~
miners.cpp:118:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  118 |             for(int i=0;i<ind2.size();++i)
      |                         ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...