結果

問題 No.1144 Triangles
ユーザー hotman78hotman78
提出日時 2020-07-24 17:41:20
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,908 bytes
コンパイル時間 5,237 ms
コンパイル使用メモリ 81,364 KB
実行使用メモリ 63,888 KB
最終ジャッジ日時 2023-09-18 16:07:47
合計ジャッジ時間 33,009 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,528 KB
testcase_01 AC 128 ms
55,904 KB
testcase_02 AC 129 ms
55,964 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 125 ms
55,744 KB
testcase_10 AC 124 ms
56,092 KB
testcase_11 AC 125 ms
56,016 KB
testcase_12 AC 124 ms
56,024 KB
testcase_13 AC 127 ms
56,108 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 384 ms
61,220 KB
testcase_20 AC 227 ms
61,612 KB
testcase_21 AC 234 ms
61,172 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 294 ms
60,732 KB
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.nio.*;
public class Main{
    public static void main(String[] args){
        Solve s=new Solve();s.solve();s.exit();
    }
}
class Solve{
    class pos{
        int x,y;
        pos(int x,int y){
            this.x=x;
            this.y=y;
        }   
    }
    public Scanner sc=new Scanner(System.in);
    void exit(){
        sc.close();
    }
    void swap(int[] v,int x,int y){
        v[x]^=v[y];
        v[y]^=v[x];
        v[x]^=v[y];
    }
    public class comp implements Comparator<pos> {
        int _pos(pos v){
            if (v.y < 0) return -1;
            if (v.y == 0 && 0 <= v.x) return 0;
            return 1;
        }
        @Override
        public int compare(pos s,pos t){
            if(_pos(s)!=_pos(t))return _pos(s)<_pos(t)?1:-1;
            else return 0<s.y*t.x-s.x*t.y?1:-1;
        }
    }
    
    void solve(){
        int n=sc.nextInt();
        int x[],y[];
        x=new int[n];
        y=new int[n];
        for(int i=0;i<n;++i){
            x[i]=sc.nextInt();
            y[i]=sc.nextInt();
        }
        long ans=0;
        for(int i=0;i<n;++i){
            ArrayList<pos>q=new ArrayList<>();
            for(int j=0;j<n;++j){
                if(x[i]==x[j]&&y[i]==y[j])continue;
                q.add(new pos(x[j]-x[i],y[j]-y[i]));
            }
            Collections.sort(q,new comp());
            int l=0,r=0;
            while((int)(l+q.size())!=0&&q.get(0).x*q.get((l+q.size())%q.size()).y-q.get(0).y*q.get((l+q.size())%q.size()).x==0)l--;
            for(int j=0;j<q.size();++j){
                if(j!=0 && q.get(j).x*q.get(j-1).y-q.get(j).y*q.get(j-1).x!=0)l=j-1;
                while(r!=(int)(j+q.size())&&q.get(j).x*q.get(r%q.size()).y-q.get(j).y*q.get(r%q.size()).x>=0)r++;
                ans+=(r-l)*(x[i]*(y[i]+q.get(j).y)-y[i]*(x[i]+q.get(j).x));
            }
        }
        System.out.println(ans);
    }
}
0