結果

問題 No.1625 三角形の質問
ユーザー chineristACchineristAC
提出日時 2021-05-07 01:29:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,312 bytes
コンパイル時間 1,843 ms
コンパイル使用メモリ 146,276 KB
実行使用メモリ 12,404 KB
最終ジャッジ日時 2023-09-25 20:39:42
合計ジャッジ時間 16,607 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 50 ms
4,380 KB
testcase_02 AC 2,249 ms
5,080 KB
testcase_03 AC 348 ms
5,728 KB
testcase_04 AC 877 ms
4,576 KB
testcase_05 AC 2,304 ms
6,540 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <random>
#include <stdio.h>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,n,c) for (int i=0;i<n;i+=c)
#define append push_back
#define all(x) (x).begin(), (x).end()

template<class T>
using vec = vector<T>;
template<class T>
using vvec = vec<vec<T>>;
template<class T>
using vvvec = vec<vvec<T>>;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using piil = tuple<ll,int,int>;

template<class T>
inline bool chmin(T &a, T b){
  if (a>b){
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool chmax(T &a, T b){
  if (a<b){
    a = b;
    return true;
  }
  return false;
}

template<class T>
T sum(vec<T> x){
  T res=0;
  for (auto e:x){
    res += e;
  }
  return res;
}

template<class T>
void printv(vec<T> x){
  for (auto e:x){
    cout<<e<<" ";
  }
  cout<<"\n";
}


const ll INF = 1e17;

const int MIN_N = 1;
const int MAX_N = 100000;
const int MIN_Q = 1;
const int MAX_Q = 100000;
const ll MIN_x = 1;
const ll MAX_x = 10^5;

inline ll area(ll a,ll b,ll c,ll d,ll e,ll f){
  ll S = (c-a)*(f-b)-(d-b)*(e-a);
  return abs(S);
}

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n,q;
  ll a,b,c,d,e,f;

  cin>>n>>q;
  vector<piil> triangle(n);
  for (int i=0;i<n;i++){
    cin>>a>>b>>c>>d>>e>>f;
    triangle[i] = {area(a,b,c,d,e,f),min({a,c,e}),max({a,c,e})};
  }
  sort(all(triangle));
  triangle.resize(n+q);
  int next_idx=n;

  int t;
  int l,r;
  ll ans=-1;
  for (int i=0;i<q;i++){
    cin>>t;
    if (t==1){
      cin>>a>>b>>c>>d>>e>>f;
      triangle[next_idx] = {area(a,b,c,d,e,f),min({a,c,e}),max({a,c,e})};
      next_idx += 1;
    }
    else{
      cin>>l>>r;
      ans=-1;
      for (int j=next_idx-1;j>n-1;j--){
        if (l<=get<1>(triangle[j]) and get<2>(triangle[j])<=r){
          chmax(ans,get<0>(triangle[j]));
        }
      }
      for (int j=n-1;j>-1;j--){
        if (l<=get<1>(triangle[j]) and get<2>(triangle[j])<=r){
          chmax(ans,get<0>(triangle[j]));
          break;
        }
      }
      cout<<ans<<"\n";
    }
  }

  
 
}
0