제출 #745214

#제출 시각아이디문제언어결과실행 시간메모리
7452141075508020060209tcRailway Trip 2 (JOI22_ho_t4)C++14
25 / 100
256 ms44600 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define X first #define Y second int n;int K; int m; int Q; vector<int>rts[200005]; int jmp[21][200005]; int rjmp[21][200005]; signed main(){ cin>>n>>K; cin>>m; for(int i=1;i<=m;i++){ int a;int b; cin>>a>>b; rts[a].push_back(b); } int mxv=0; for(int i=1;i<=n;i++){ for(int j=0;j<rts[i].size();j++){ mxv=max(mxv,rts[i][j]); } jmp[0][i]=max(i,mxv); } mxv=n+1; for(int i=n;i>=1;i--){ for(int j=0;j<rts[i].size();j++){ mxv=min(mxv,rts[i][j]); } rjmp[0][i]=min(i,mxv); } for(int i=1;i<=20;i++){ for(int j=1;j<=n;j++){ jmp[i][j]=jmp[i-1][jmp[i-1][j]]; rjmp[i][j]=rjmp[i-1][rjmp[i-1][j]]; } } cin>>Q; while(Q--){ int stp;int enp; cin>>stp>>enp; int ans=0; if(stp<enp){ int nw=stp; for(int i=20;i>=0;i--){ if(jmp[i][nw]<enp){ ans+=(1<<i); nw=jmp[i][nw]; } } if(jmp[0][nw]<enp){ ans=-1; }else{ ans++; } }else{ int nw=stp; for(int i=20;i>=0;i--){ if(rjmp[i][nw]>enp){ ans+=(1<<i); nw=rjmp[i][nw]; } } if(rjmp[0][nw]>enp){ ans=-1; }else{ ans++; } // cout<<nw<<" "; } cout<<ans<<endl; } }

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

Main.cpp: In function 'int main()':
Main.cpp:24:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int j=0;j<rts[i].size();j++){
      |                 ~^~~~~~~~~~~~~~
Main.cpp:31:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int j=0;j<rts[i].size();j++){
      |                 ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...