Submission #163191

#TimeUsernameProblemLanguageResultExecution timeMemory
163191TadijaSebez버스 (JOI14_bus)C++11
100 / 100
757 ms40360 KiB
#include <bits/stdc++.h> using namespace std; const int N=100050; const int M=3*N; map<int,int> dp[N]; int u[M],v[M],l[M],r[M],id[M]; int Get(int u, int tme){ return (--dp[u].upper_bound(tme))->second;} int main() { int n,m,q; scanf("%i %i",&n,&m); for(int i=1;i<=n;i++) dp[i][-1]=-1; for(int i=1;i<=m;i++) { scanf("%i %i %i %i",&u[i],&v[i],&l[i],&r[i]); if(u[i]==1) dp[1][l[i]]=l[i]; if(v[i]==1) dp[1][r[i]]=r[i]; id[i]=i; } sort(id+1,id+1+m,[&](int i, int j){ return r[i]<r[j];}); for(int j=1;j<=m;j++) { int i=id[j]; int mx=max(Get(v[i],r[i]),Get(u[i],l[i])); dp[v[i]][r[i]]=mx; } scanf("%i",&q); while(q--) { int x; scanf("%i",&x); printf("%i\n",Get(n,x)); } return 0; }

Compilation message (stderr)

bus.cpp: In function 'int main()':
bus.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
bus.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i %i %i %i",&u[i],&v[i],&l[i],&r[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bus.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&q);
  ~~~~~^~~~~~~~~
bus.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i",&x);
   ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...