結果
問題 | No.1625 三角形の質問 |
ユーザー | ei1333333 |
提出日時 | 2021-07-23 23:02:11 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,201 bytes |
コンパイル時間 | 2,689 ms |
コンパイル使用メモリ | 219,080 KB |
実行使用メモリ | 21,852 KB |
最終ジャッジ日時 | 2024-07-18 20:06:46 |
合計ジャッジ時間 | 30,850 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | RE | - |
testcase_06 | WA | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | WA | - |
testcase_15 | RE | - |
testcase_16 | WA | - |
testcase_17 | RE | - |
testcase_18 | WA | - |
testcase_19 | RE | - |
ソースコード
#include<bits/stdc++.h> using namespace std; using int64 = long long; // const int mod = 1e9 + 7; const int mod = 998244353; const int64 infll = (1LL << 62) - 1; const int inf = (1 << 30) - 1; struct IoSetup { IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup; template< typename T1, typename T2 > ostream &operator<<(ostream &os, const pair< T1, T2 > &p) { os << p.first << " " << p.second; return os; } template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; } template< typename T > ostream &operator<<(ostream &os, const vector< T > &v) { for(int i = 0; i < (int) v.size(); i++) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; } template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); } template< typename T = int64 > vector< T > make_v(size_t a) { return vector< T >(a); } template< typename T, typename... Ts > auto make_v(size_t a, Ts... ts) { return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...)); } template< typename T, typename V > typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) { t = v; } template< typename T, typename V > typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); } template< typename F > struct FixPoint : F { FixPoint(F &&f) : F(forward< F >(f)) {} template< typename... Args > decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, forward< Args >(args)...); } }; template< typename F > inline decltype(auto) MFP(F &&f) { return FixPoint< F >{forward< F >(f)}; } int main() { int N, Q; cin >> N >> Q; auto T = make_v< int64 >(N, 6); cin >> T; auto get_area = [&](vector< int64 > &xs) { int64 x1 = xs[0]; int64 y1 = xs[1]; int64 x2 = xs[2]; int64 y2 = xs[3]; int64 x3 = xs[4]; int64 y3 = xs[5]; return abs((x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)); }; for(auto &v : T) v.emplace_back(get_area(v)); vector< vector< int64 > > qs; int B = 333; for(int i = 0; i < Q; i++) { int t; cin >> t; if(t == 1) { vector< int64 > X(6); cin >> X; X.emplace_back(get_area(X)); qs.emplace_back(X); } else { vector< int64 > X(2); cin >> X; qs.emplace_back(X); } if(qs.size() >= B or i + 1 == Q) { vector< int > xs; for(auto &vs : qs) { if(vs.size() == 2) { xs.emplace_back(vs[0]); xs.emplace_back(vs[1]); } } sort(begin(xs), end(xs)); xs.erase(unique(begin(xs), end(xs)), end(xs)); auto cost = make_v< int64 >(xs.size(), xs.size()); fill_v(cost, -1); for(auto v : T) { auto[l, r]=minmax({v[0], v[2], v[4]}); l = lower_bound(begin(xs), end(xs), l) - begin(xs); r = lower_bound(begin(xs), end(xs), r) - begin(xs); chmax(cost[l][r], v[6]); } for(int d = 0; d < xs.size(); d++) { for(int l = 0; l + d < xs.size(); l++) { if(l) chmax(cost[l - 1][l + d], cost[l][l + d]); if(l + d + 1 < xs.size()) chmax(cost[l][l + d + 1], cost[l][l + d]); } } vector< int64 > ans; int ps = (int) T.size(); for(auto &vs : qs) { if(vs.size() == 2) { int l = lower_bound(begin(xs), end(xs), vs[0]) - begin(xs); int r = lower_bound(begin(xs), end(xs), vs[1]) - begin(xs); int64 ret = cost[l][r]; for(int j = ps; j < T.size(); j++) { auto &v = T[j]; auto[l, r]=minmax({v[0], v[2], v[4]}); if(vs[0] <= l and r <= vs[1]) chmax(ret, v[6]); } cout << ret << "\n"; } else { T.emplace_back(vs); } } qs.clear(); } } }