제출 #850246

#제출 시각아이디문제언어결과실행 시간메모리
850246elotelo966Portal (COCI17_portal)C++17
36 / 120
13 ms11672 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int #define OYY 100000005 #define mod 100000007 #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define mid (start+end)/2 #define lim 505 int n,m,yol[lim][lim],xd[4]={0,0,1,-1},yd[4]={1,-1,0,0},vis[lim][lim]; char dizi[lim][lim]; vector<int> cev,as; inline void dfs(int x,int y,int gel){ //cout<<x<<" "<<y<<" " <<gel<<endl; if(x<0 || x>=n || y<0 || y>=m)return ; if(vis[x][y])return ; if(dizi[x][y]=='#')return ; vis[x][y]=1; yol[x][y]=gel; int tut=0; for(int i=gel;i<4;i++){ tut++; dfs(x+xd[i],y+yd[i],i); } for(int i=0;i<4-tut;i++){ dfs(x+xd[i],y+yd[i],i); } } int32_t main(){ faster cin>>n>>m; string deg; int bx,by,ex,ey; for(int i=0;i<n;i++){ cin>>deg; for(int j=0;j<m;j++){ dizi[i][j]=deg[j]; if(dizi[i][j]=='C'){ bx=i,by=j; } else if(dizi[i][j]=='F'){ ex=i,ey=j; } } } dfs(bx,by,0); if(vis[ex][ey]){ int i=ex,j=ey; cev.push_back(yol[i][j]); while(!(i==bx && j==by)){ if(yol[i][j]==0)j--; else if(yol[i][j]==1)j++; else if(yol[i][j]==2)i--; else if(yol[i][j]==3)i++; cev.push_back(yol[i][j]); } /*for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ cout<<yol[i][j]<<" "; } cout<<endl; }*/ as.push_back(cev[0]); for(int i=1;i<cev.size();i++){ if(cev[i]!=as.back()){ as.push_back(cev[i]); } } cout<<as.size()<<'\n'; } else cout<<"nemoguce"<<'\n'; return 0; }

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

portal.cpp: In function 'int32_t main()':
portal.cpp:65:22: 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]
   65 |         for(int i=1;i<cev.size();i++){
      |                     ~^~~~~~~~~~~
portal.cpp:34:18: warning: 'ey' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |     int bx,by,ex,ey;
      |                  ^~
portal.cpp:34:15: warning: 'ex' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |     int bx,by,ex,ey;
      |               ^~
portal.cpp:16:16: warning: 'by' may be used uninitialized in this function [-Wmaybe-uninitialized]
   16 |     if(vis[x][y])return ;
      |        ~~~~~~~~^
portal.cpp:34:12: note: 'by' was declared here
   34 |     int bx,by,ex,ey;
      |            ^~
portal.cpp:15:20: warning: 'bx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   15 |     if(x<0 || x>=n || y<0 || y>=m)return ;
      |        ~~~~~~~~~~~~^~~~~~
portal.cpp:34:9: note: 'bx' was declared here
   34 |     int bx,by,ex,ey;
      |         ^~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...