結果
問題 | No.245 貫け! |
ユーザー |
|
提出日時 | 2015-07-17 23:22:07 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 946 bytes |
コンパイル時間 | 533 ms |
コンパイル使用メモリ | 76,400 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-08 09:31:31 |
合計ジャッジ時間 | 1,224 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 3 WA * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:24:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 24 | scanf("%d%d%d%d",&sx,&sy,&ex,&ey); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <vector> #include <complex> #include <algorithm> #include <numeric> #include <cstdio> #include <cfloat> using namespace std; typedef int val_t; typedef complex<val_t> P; typedef vector<P> VP; val_t cross(const P &a,const P &b){return (conj(a)*b).imag();} val_t dot(const P &a,const P &b){return (conj(a)*b).real();} bool intersectLS(const VP &l, const VP &s) { return cross(l[1]-l[0], s[0]-l[0])* // s[0] is left of l cross(l[1]-l[0], s[1]-l[0]) == 0; // s[1] is right of l } int main(){ int n; scanf("%d",&n); vector<VP> lst(n); for(int i=0;i<n;i++){ int sx,sy,ex,ey; scanf("%d%d%d%d",&sx,&sy,&ex,&ey); lst[i]={P(sx,sy),P(ex,ey)}; } int R=0; for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){ vector<VP> x={{lst[i][0],lst[j][0]},{lst[i][1],lst[j][0]},{lst[i][0],lst[j][1]},{lst[i][1],lst[j][1]}}; for(auto &e:x){ int r=0; for(int k=0;k<n;k++)r+=intersectLS(e,lst[k]); if(R<r)R=r; } } printf("%d\n",R); }