Submission #341351

#TimeUsernameProblemLanguageResultExecution timeMemory
341351hackxsarasMiners (IOI07_miners)C++14
18 / 100
600 ms211992 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long #define pb push_back int n; string s; gp_hash_table<ll, ll> dp; ll hashit(int &k, deque<char> &a, deque<char> &b){ ll ans = 0; for(int i=0;i<a.size();i++){ ans ^= (a[i] - 'A'); } for(int j=0;j<b.size();j++){ ans ^= (b[j] - 'A'); } return (k*n) + (ans); } int recurse(int index, deque<char> &a, deque<char> &b){ if(index == n)return 0; if(dp[hashit(index, a, b)])return dp[hashit(index, a, b)]; set<int> sa, sb; for(int i=0;i<a.size();i++)sa.insert(a[i]); for(int i=0;i<b.size();i++)sb.insert(b[i]); deque<char> qa = a, qb = b; if(qa.size() == 2)qa.pop_front(); if(qb.size() == 2)qb.pop_front(); qa.pb(s[index]); qb.pb(s[index]); sa.insert(s[index]); sb.insert(s[index]); return dp[hashit(index, a, b)] = max(sa.size() + recurse(index+1, qa, b) , sb.size() + recurse(index+1, a, qb)); } void solve(){ cin >> n; cin >> s; deque<char> ep, ep2; cout<<recurse(0, ep, ep2); } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; // cin>>t; while(t--){ solve(); } return 0; }

Compilation message (stderr)

miners.cpp: In function 'long long int hashit(int&, std::deque<char>&, std::deque<char>&)':
miners.cpp:20:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for(int i=0;i<a.size();i++){
      |              ~^~~~~~~~~
miners.cpp:23:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int j=0;j<b.size();j++){
      |              ~^~~~~~~~~
miners.cpp: In function 'int recurse(int, std::deque<char>&, std::deque<char>&)':
miners.cpp:37:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for(int i=0;i<a.size();i++)sa.insert(a[i]);
      |              ~^~~~~~~~~
miners.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for(int i=0;i<b.size();i++)sb.insert(b[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...