제출 #341343

#제출 시각아이디문제언어결과실행 시간메모리
341343hackxsarasMiners (IOI07_miners)C++14
68 / 100
1617 ms524292 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back int n; string s; map<pair<int, pair<deque<char>, deque<char>>>, int> dp; int recurse(int index, deque<char> a, deque<char> b){ if(index == n)return 0; if(dp[{index, {a, b}}])return dp[{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[{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; cout<<recurse(0, ep, ep); } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; // cin>>t; while(t--){ solve(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

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