Submission #1689709
Source Code Expand
#include <iostream> #include <vector> #include <string.h> #include <stack> #include <queue> #include <algorithm> #include <climits> #include <cmath> #include <map> #include <set> #include <assert.h> #include <sstream> #define REP(i,n) for(ll i=0;i<(n);i++) #define MOD 1000000007 #define int long long #ifdef int const long long INF = LLONG_MAX / 10; #else const int INF = 1010101010; #endif using namespace std; typedef long long ll; typedef vector<vector<ll>> mat; typedef pair<int, int> P; //typedef pair<double, double> P; #ifdef LOCAL #define dump(...) \ do { \ std::ostringstream os; \ os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \ print_to(os, ", ", "\n", __VA_ARGS__); \ std::cerr << os.str(); \ } while (0) #define dump_(a) \ do { \ std::ostringstream os; \ os << __LINE__ << ":\t" << #a << " = ["; \ print_to_(os, ", ", "]\n", all(a)); \ std::cerr << os.str(); \ } while (0) #else #define dump(...) #define dump_(...) #endif template <typename T> void print_to(std::ostream &os, const char *, const char *tail, const T &fst) { os << fst << tail; } template <typename Fst, typename... Rst> void print_to(std::ostream &os, const char *del, const char *tail, const Fst &fst, const Rst &... rst) { os << fst << del; print_to(os, del, tail, rst...); } template <typename Iter> void print_to_(std::ostream &os, const char *del, const char *tail, Iter bgn, Iter end) { for (Iter it = bgn; it != end;) { os << *it; if (++it != end) { os << del; } else { os << tail; } } } template <typename Fst, typename... Rst> void println(const Fst &fst, const Rst &... rst) { print_to(std::cout, "\n", "\n", fst, rst...); } template <typename Fst, typename... Rst> void print(const Fst &fst, const Rst &... rst) { print_to(std::cout, " ", "\n", fst, rst...); } template <typename Iter> void println_(Iter bgn, Iter end) { print_to_(std::cout, "\n", "\n", bgn, end); } template <typename Iter> void print_(Iter bgn, Iter end) { print_to_(std::cout, " ", "\n", bgn, end); } // const int MOD = 1000000007; namespace trush { int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0), std::ios::sync_with_stdio(0), 0); } string S; int dp[110][110][310]; signed main() { cin >> S; REP(i,110) REP(j,110) REP(k,310) dp[i][j][k] = -INF; dp[0][0][0] = (S[0] == '(' ? 1 : -1); REP(i,S.length()-1) { REP(j,110) { REP(k,310) { if (dp[i][j][k] != -INF) { //変えない if (dp[i][j][k] + (S[i+1] == '(' ? 1 : -1) >= 0) dp[i+1][j][k+1] = dp[i][j][k] + (S[i+1] == '(' ? 1 : -1); //変える if (dp[i][j][k] + (S[i+1] == '(' ? -1 : 1) >= 0) dp[i+1][i+2][k+2] = dp[i][j][k] + (S[i+1] == '(' ? -1 : 1); } } } } int ans = INF; REP(j,110) REP(k,310) if (dp[S.length()-1][j][k] == 0) { //dump(j, k, S.length()); ans = min(ans, k - (S.length() - j)); } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | B - 天下一魔力発電 |
User | hiyokko2 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 3665 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:117:44: error: no matching function for call to ‘min(long long int&, long long unsigned int)’ ans = min(ans, k - (S.length() - j)); ^ In file included from /usr/include/c++/5/bits/char_traits.h:39:0, from /usr/include/c++/5/ios:40, from /usr/include/c++/5/ostream:38, from /usr/include/c++/5/iostream:39, from ./Main.cpp:1: /usr/include/c++/5/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&) min(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/5/bits/stl_algobase.h:195:5: note: template argument deduction/substitution failed: ./Main.cpp:117:44: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘long long unsigned int’) ans = min(ans, k - (S.length() - j)); ^ In file included from...