제출 #1099369

#제출 시각아이디문제언어결과실행 시간메모리
1099369RajCircle Passing (EGOI24_circlepassing)C++11
0 / 100
2079 ms1048576 KiB
#include <stdio.h> #include <iostream> #include <stdlib.h> #include <queue> #include <string.h> int n,m,q; int v[50001]; std::pair<int,int> per[50001]; int cautare(int a,int b) { int cnt=0; std::queue<std::pair<int,int>> co; co.push({a,0}); while(!co.empty()) { int x=co.front().first; int t=co.front().second; if(x==b) return t; int st=x-1,dr=x+1; if(st<0) st=2*n-1; if(dr>n*2-1) dr=0; if(x==b) return cnt; else cnt++; co.pop(); co.push({st,t+1}); co.push({dr,t+1}); if(v[x]!=-1) { if(x<n) co.push({x+n,t+1}); else co.push({x-n,t+1}); } } } int main() { std::cin>>n>>m>>q; for(int i=1;i<=m;++i) { int x; std::cin>>x; if(x>=n) v[x-n]=1; else v[x]=1; } for(int i=1;i<=q;++i) std::cin>>per[i].first>>per[i].second; for(int i=1;i<=q;++i) { int x1=per[i].first,y1=per[i].second; std::cout<<cautare(x1,y1)<<'\n'; } return 0; }

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

Main.cpp: In function 'int cautare(int, int)':
Main.cpp:12:36: warning: control reaches end of non-void function [-Wreturn-type]
   12 |     std::queue<std::pair<int,int>> co;
      |                                    ^~
#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...