제출 #776516

#제출 시각아이디문제언어결과실행 시간메모리
776516jamielimDragon 2 (JOI17_dragon2)C++14
0 / 100
858 ms262144 KiB
#include <bits/stdc++.h> using namespace std; #define pb emplace_back #define mp make_pair #define fi first #define se second #define SZ(x) (int)x.size() #define ALL(x) x.begin(),x.end() typedef pair<int,int> ii; typedef long long ll; typedef unsigned long long ull; const int INF=1012345678; const ll LLINF=1012345678012345678LL; const ll MOD=1000000007; int n,m; vector<ii> tribe[30005]; vector<int> adj[30005]; int d1,e1,d2,e2; int q; double road(int x){ double m=(double)(e2-e1)/(d2-d1); return m*(x-d1)+e1; } inline bool ixn(ii p1,ii p2){ //printf("try %d %d %d %d\n",p1.fi,p1.se,p2.fi,p2.se); if(p1.fi==p2.fi){ //printf("a\n"); if(d1>p1.fi||d2<p1.fi)return 0; // x coordinate is correct if(p1.se<p2.se){ if(p2.se<road(p1.fi))return 1; }else{ if(p2.se>road(p1.fi))return 1; } }else{ //printf("b\n"); double m=(double)(p2.se-p1.se)/(double)(p2.fi-p1.fi); if(d1==d2){ double y=m*(d1-p2.fi)+p2.se; if(e1<y&&y<e2)return 1; }else{ if(p1.fi<p2.fi){ double a=p1.se,b=m*(d2-p2.fi)+p2.se; if(p1.fi<d1)a=m*(d1-p2.fi)+p2.se; double r=road(p1.fi); //printf("%lf %lf %d %lf\n",a,r,e2,b); if(a<r&&e2<b)return 1; if(a>r&&e2>b)return 1; }else{ double a=m*(d1-p2.fi)+p2.se,b=p1.se; if(p1.fi>d2)b=m*(d2-p2.fi)+p2.se; double r=road(p1.fi); if(a<e1&&r<b)return 1; if(a>e1&&r>b)return 1; } } } return 0; } int main(){ scanf("%d%d",&n,&m); int a,b,c; for(int i=0;i<n;i++){ scanf("%d%d%d",&a,&b,&c); tribe[c].pb(a,b); } scanf("%d%d%d%d",&d1,&e1,&d2,&e2); if(d1>d2){ swap(d1,d2); swap(e1,e2); }else if(d1==d2){ if(e1>e2)swap(e1,e2); } for(int i=1;i<=m;i++){ for(int j=1;j<=m;j++){ if(i==j)continue; for(ii k:tribe[i]){ for(ii l:tribe[j]){ if(ixn(k,l)){ // printf("1\n"); adj[i].pb(j); }else{ // printf("0\n"); } } } } } scanf("%d",&q); while(q--){ scanf("%d%d",&a,&b); int ans=0; for(int i:adj[a]){ if(i==b)ans++; } printf("%d\n",ans); } }

컴파일 시 표준 에러 (stderr) 메시지

dragon2.cpp: In function 'int main()':
dragon2.cpp:66:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |  scanf("%d%d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~
dragon2.cpp:69:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |   scanf("%d%d%d",&a,&b,&c);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
dragon2.cpp:72:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |  scanf("%d%d%d%d",&d1,&e1,&d2,&e2);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
dragon2.cpp:94:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   94 |  scanf("%d",&q);
      |  ~~~~~^~~~~~~~~
dragon2.cpp:96:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   96 |   scanf("%d%d",&a,&b);
      |   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...