結果

問題 No.1625 三角形の質問
ユーザー chineristAC
提出日時 2021-05-07 01:29:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,312 bytes
コンパイル時間 1,586 ms
コンパイル使用メモリ 147,808 KB
最終ジャッジ日時 2025-01-21 07:50:32
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8 TLE * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:76:20: warning: result of ‘10^5’ is 15; did you mean ‘1e5’? [-Wxor-used-as-pow]
   76 | const ll MAX_x = 10^5;
      |                    ^
      |                  ---
      |                  1e
main.cpp:76:18: note: you can silence this warning by using a hexadecimal constant (0xa rather than 10)
   76 | const ll MAX_x = 10^5;
      |                  ^~
      |                  0xa

ソースコード

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