結果

問題 No.1041 直線大学
ユーザー motmot
提出日時 2020-05-01 21:38:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,963 bytes
コンパイル時間 1,130 ms
コンパイル使用メモリ 78,828 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 07:58:50
合計ジャッジ時間 2,449 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 8 ms
4,376 KB
testcase_15 AC 3 ms
4,384 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,380 KB
testcase_21 WA -
testcase_22 AC 2 ms
4,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:65:36: warning: ‘tmpans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
                     if(xx==0)tmpans++;
                              ~~~~~~^~

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int gcd(int x, int y){
    int v0 = x, v1 = y, v2 = x % y;
    while(v2!=0){
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    }
    return v1;
}

int main() {
    int N;
    cin>>N;
    vector<int> X(N), Y(N);
    for(int i=0;i<N;++i){
        cin>>X[i]>>Y[i];
    }
    int x, y, xx, yy;
    int tmp;
    int tmpans;
    int ans = 0;
    for(int i=0;i<N;++i){
        for(int j=0;j<i;++j){
            x = X[i] - X[j];
            y = Y[i] - Y[j];
            if((x!=0) & (y!=0)){
                tmp = gcd(x, y);
                x /= tmp;
                y /= tmp;
                tmpans = 2;
                for(int k=0;k<N;++k){
                    if((k==i) | (k==j)) continue;
                    xx = X[i] - X[k];
                    yy = Y[i] - Y[k];
                    if((xx==0) | (yy==0)) continue;
                    tmp = gcd(xx, yy);
                    xx /= tmp;
                    yy /= tmp;
                    if(((x==xx) & (y==yy)) | ((x==-xx) & (y==-yy))) tmpans++;
                }
                if(ans < tmpans) ans = tmpans;
            }
            else if(x==0){
                for(int k=0;k<N;++k){
                    if((k==i) | (k==j)) continue;
                    xx = X[i] - X[k];
                    if(xx==0)tmpans++;
                }
                if(ans < tmpans) ans = tmpans;
            }
            else {
                for(int k=0;k<N;++k){
                    if((k==i) | (k==j)) continue;
                    yy = Y[i] - Y[k];
                    if(yy==0) tmpans++;
                }
                if(ans < tmpans) ans = tmpans;
            }
        }
    }
    cout<<ans<<endl;
}

0