結果

問題 No.743 Segments on a Polygon
ユーザー Nakayama YusukeNakayama Yusuke
提出日時 2018-10-15 16:32:18
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 724 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 30,976 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 20:28:27
合計ジャッジ時間 2,852 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
int main(){
    int n,m,i,j,cross;
    int *a,*b;
    
    scanf("%d %d", &n, &m);
    a = (int*)malloc(n);
    b = (int*)malloc(n);
    
    for ( i = 0; i < n; i++){
        scanf("%d %d", &a[i], &b[i]);
    }
    
    cross = 0;
    
    for ( i = 0; i < n-1; i++){
        for (j = i+1; j < n; j++){
            if( a[j] < a[i] || b[i] < a[j]){
                if ( a[i]<b[j] || b[j] < b[i]){
                    cross +=1;
                }
            }
            else if ( a[j] > a[i] || b[i] > a[j]){
                if( a[i] > b[j] || b[j] > b[i]){
                    cross += 1;
                }
            }
        }
    }
    printf("%d", cross/2);
    
    return 0;
}
0