제출 #762798

#제출 시각아이디문제언어결과실행 시간메모리
762798MarwenElarbi바이러스 (JOI19_virus)C++17
0 / 100
2 ms468 KiB
#include <bits/stdc++.h> #define pb push_back #define ll long long #define fi first #define se second using namespace std; const int MOD=1e9+7; const int nax=1e5+5; int m,r,c; bool vis[50][50]; int grid[50][50]; int e=0; int w=0; int dfs(int x,int y) { if (vis[x][y]) return 0; vis[x][y]=true; int ans=0; //cout <<x<<" "<<y<<" "<<grid[x][y+1]<<" "<<w<<endl; if(y<c-1&&w>=grid[x][y+1]&&!vis[x][y+1]){ ans+=dfs(x,y+1)+1; }else if(y>0&&e>=grid[x][y-1]&&!vis[x][y-1]){ ans+=dfs(x,y-1)+1; } return ans; } int main() { /*#ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif*/ string t; cin>>m>>r>>c; cin>>t; int cur=0; bool test=false; int grid[r][c]; for (int i = 0; i < m; ++i) { int cur; if (!test) cur=0; if (t[i]=='W'){ while(t[i]=='W'){ i++; cur++; } w=max(w,cur); i--; if (test) break; }else if(t[i]=='E'){ while(t[i]=='E'){ i++; cur++; } e=max(e,cur); i--; if (test) break; } if (i==m-1&&t[m-1]==t[0]){ i=-1; test=true; } } //cout << e<<" "<<w<<endl; for (int i = 0; i < r; ++i) { for (int j = 0; j < c; ++j) { cin>>grid[i][j]; } } int ans=1e9; int time=0; memset(vis,0,sizeof vis); for (int i = 0; i < r; ++i) { for (int j = 0; j < c; ++j) { if (grid[i][j]==0) continue; int cur=dfs(i,j); //cout << cur<<" "; if (cur==0) continue; if (cur<ans){ ans=cur; time=1; }else if(cur==ans) time++; }//cout << endl; } cout << ans <<endl; cout << time<<endl; }

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

virus.cpp: In function 'int main()':
virus.cpp:36:6: warning: unused variable 'cur' [-Wunused-variable]
   36 |  int cur=0;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...