結果

問題 No.1041 直線大学
ユーザー takayusamuraitakayusamurai
提出日時 2020-05-02 14:24:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 1,346 ms
コンパイル使用メモリ 167,552 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-28 17:19:09
合計ジャッジ時間 5,351 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 WA -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:18:9: 警告: ‘cnt’ may be used uninitialized [-Wmaybe-uninitialized]
   18 |     int cnt;
      |         ^~~

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
  int n; cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  rep(i,n) {
    cin >> x[i] >> y[i];
  }
  int ans = 0;
  
  rep(i,n) {
    int cnt;
    rep(j,n) {
      if (i==j) continue;
      cnt=1;
      if (x[j]==x[i]) {
        rep(k,n) {if (i!=k && j!=k && x[k]==x[i]) cnt++;}
        ans = max(cnt, ans);
        continue;
      }
      double a1 = abs((y[j] - y[i]) / (x[j] - x[i]));
      rep(k,n) {
        if (i==k || j==k) continue;
        double a2 = abs((y[k] - y[i]) / (x[k] - x[i]));
        if (abs(a1-a2) < 0.0001) cnt++;
      }
    }
    ans = max(cnt, ans);
  }
  cout << ans << endl;

}
0