結果
問題 | No.1029 JJOOII 3 |
ユーザー | 👑 emthrm |
提出日時 | 2020-04-17 22:05:52 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,032 bytes |
コンパイル時間 | 3,168 ms |
コンパイル使用メモリ | 214,660 KB |
最終ジャッジ日時 | 2024-04-14 14:16:54 |
合計ジャッジ時間 | 3,724 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/string:43, from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bitset:52, from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/x86_64-pc-linux-gnu/bits/stdc++.h:52, from main.cpp:6: /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()': /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch 184 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/string:54: /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/basic_string.h:181:14: note: called from here 181 | struct _Alloc_hider : allocator_type // TODO check __is_final | ^~~~~~~~~~~~
ソースコード
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline") #pragma GCC option("arch=native", "tune=native", "no-zero-upper") #pragma GCC target("avx2") #define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // const int MOD = 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); } } iosetup; int main() { int n, k; cin >> n >> k; vector<string> s(n); vector<int> c(n); REP(i, n) cin >> s[i] >> c[i]; { bool j = false, o = false, I = false; REP(i, n) for (char c : s[i]) { j |= c == 'J'; o |= c == 'O'; I |= c == 'I'; } // cout << j << ' ' << o << ' ' << i << '\n'; if (!j || !o || !I) { cout << "-1\n"; return 0; } } vector<ll> dp(k * 3 + 1, LINF); dp[0] = 0; REP(i, k * 3) REP(j, n) { int status, cnt = i % k; if (i < k) status = 0; if (k <= i && i < k * 2) status = 1; if (k * 2 <= i) status = 2; for (char c : s[j]) { if (status == 0) { if (c == 'J') ++cnt; } else if (status == 1) { if (c == 'O') ++cnt; } else if (status == 2) { if (c == 'I') ++cnt; } if (cnt == k && status < 2) { status = status + 1; cnt = 0; } } chmin(cnt, k); chmin(dp[status * k + cnt], dp[i] + c[j]); } cout << dp[k * 3] << '\n'; return 0; }