結果
問題 | No.962 LCPs |
ユーザー | firiexp |
提出日時 | 2019-12-24 23:43:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,634 bytes |
コンパイル時間 | 852 ms |
コンパイル使用メモリ | 93,440 KB |
最終ジャッジ日時 | 2024-11-14 22:00:09 |
合計ジャッジ時間 | 2,368 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:46:24: error: too many initializers for 'P' {aka 'std::array<int, 3>'} 46 | Q.emplace(P{0, n, 0}); | ^ main.cpp:49:11: error: variable 'P x' has initializer but incomplete type 49 | P x = Q.front(); Q.pop(); | ^ main.cpp:62:57: error: too many initializers for 'P' {aka 'std::array<int, 3>'} 62 | Q.emplace(P{cur, cur+a[i].second, x[2]+1}); | ^ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/deque:64, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/queue:60, from main.cpp:6: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_deque.h: In instantiation of 'void std::deque<_Tp, _Alloc>::_M_destroy_data(iterator, iterator, const std::allocator<_CharT>&) [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; iterator = std::_Deque_base<std::array<int, 3>, std::allocator<std::array<int, 3> > >::iterator]': /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_deque.h:1028:24: required from 'std::deque<_Tp, _Alloc>::~deque() [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >]' /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_queue.h:96:11: required from here /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_deque.h:2090:14: error: invalid use of incomplete type 'std::deque<std::array<int, 3>, std::allocator<std::array<int, 3> > >::value_type' {aka 'struct std::array<int, 3>'} 2090 | if (!__has_trivial_destructor(value_type)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_map.h:63, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/incl
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <cmath> #include <limits> static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using u64 = unsigned long long; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; template <class T> ostream& operator<<(ostream& os, vector<T> v) { os << "{"; for (int i = 0; i < v.size(); ++i) { if(i) os << ", "; os << v[i]; } return os << "}"; } template <class L, class R> ostream& operator<<(ostream& os, pair<L, R> p) { return os << "{" << p.first << ", " << p.second << "}"; } int main() { int n; cin >> n; vector<string> v(n); for (auto &&i : v) cin >> i; ll ans = 0; using P = array<int, 3>; queue<P> Q; Q.emplace(P{0, n, 0}); vector<pair<char, int>> a; while(!Q.empty()){ P x = Q.front(); Q.pop(); a.clear(); a.emplace_back(0, 0); for (int i = x[0]; i < x[1]; ++i) { char nxt = 0; if(x[2] < v[i].size()) nxt = v[i][x[2]]; if(a.back().first != nxt) a.emplace_back(nxt, 1); else a.back().second++; } int cur = x[0]; for (int i = 0; i < a.size(); ++i) { if(a[i].first){ ans += (ll)(a[i].second)*(a[i].second+1)*(a[i].second+2)/6; Q.emplace(P{cur, cur+a[i].second, x[2]+1}); } cur += a[i].second; } } cout << ans << "\n"; return 0; }