結果

問題 No.1447 Greedy MtSaka
ユーザー butsurizukibutsurizuki
提出日時 2021-03-30 02:35:03
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 786 bytes
コンパイル時間 7,524 ms
コンパイル使用メモリ 307,896 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 00:10:57
合計ジャッジ時間 8,453 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include "testlib.h"

using namespace std;
using pi=pair<int,int>;

int cp(pi a,pi b){
  return a.first*b.second-a.second*b.first;
}

pi vm(pi a,pi b){
  return make_pair(a.first-b.first,a.second-b.second);
}

int main(int argc, char* argv[]){
  registerValidation(argc, argv);
  int n=inf.readInt(3,30);inf.readEoln();
  vector<pi> vp(n);
  for(int i=0;i<n;i++){
    vp[i].first=inf.readInt(-10000,10000);inf.readSpace();
    vp[i].second=inf.readInt(-10000,10000);inf.readEoln();
  }
  for(int i=0;i<n;i++){
    ensuref(cp(vm(vp[(i+1)%n],vp[i]),vm(vp[(i+2)%n],vp[(i+1)%n]))>0,"the points aren't clockwise");
  }
  int res=0;
  for(int i=2;i<n;i++){
    res+=abs(cp(vm(vp[i-1],vp[0]),vm(vp[i],vp[0])));
  }
  cout << res << '\n';
  inf.readEof();
  return 0;
}
0