結果

問題 No.1144 Triangles
ユーザー hotman78hotman78
提出日時 2020-07-24 18:33:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,115 bytes
コンパイル時間 2,330 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 63,960 KB
最終ジャッジ日時 2023-09-18 16:09:51
合計ジャッジ時間 31,350 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
55,508 KB
testcase_01 AC 129 ms
55,716 KB
testcase_02 AC 130 ms
55,724 KB
testcase_03 AC 131 ms
55,488 KB
testcase_04 AC 2,002 ms
61,812 KB
testcase_05 AC 1,801 ms
61,616 KB
testcase_06 AC 1,934 ms
61,800 KB
testcase_07 WA -
testcase_08 AC 1,749 ms
61,700 KB
testcase_09 AC 130 ms
55,668 KB
testcase_10 AC 130 ms
55,672 KB
testcase_11 AC 130 ms
53,720 KB
testcase_12 AC 128 ms
55,516 KB
testcase_13 AC 128 ms
55,956 KB
testcase_14 AC 1,747 ms
61,728 KB
testcase_15 AC 1,772 ms
61,824 KB
testcase_16 AC 1,755 ms
61,736 KB
testcase_17 AC 1,859 ms
61,880 KB
testcase_18 AC 1,843 ms
61,536 KB
testcase_19 AC 456 ms
61,796 KB
testcase_20 AC 246 ms
59,864 KB
testcase_21 AC 247 ms
60,100 KB
testcase_22 AC 1,838 ms
61,864 KB
testcase_23 AC 489 ms
61,328 KB
testcase_24 AC 1,837 ms
61,488 KB
testcase_25 AC 1,014 ms
61,748 KB
testcase_26 AC 389 ms
61,064 KB
testcase_27 AC 289 ms
60,800 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{
        long x,y;
        pos(long x,long 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(s.x==t.x && s.y==t.y)return 0;
            if(_pos(s)!=_pos(t))return _pos(s)<_pos(t)?-1:1;
            else return (0<s.x*t.y-s.y*t.x)?-1:1;
        }
    }
    
    long conv(long x){
        if(x<0)return 1000000007L-(-x)%1000000007L;
        else return x%1000000007L;
    }
    void solve(){
        int n=sc.nextInt();
        long x[],y[];
        x=new long[n];
        y=new long[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)*conv(x[i]*(y[i]+q.get(j).y)-y[i]*(x[i]+q.get(j).x));
                ans%=1000000007;
            }
        }
        System.out.println(ans);
    }
}
0