Submission #762822

#TimeUsernameProblemLanguageResultExecution timeMemory
762822vjudge1Virus Experiment (JOI19_virus)C++17
0 / 100
1 ms340 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[55][55]; int e; int w; int cnt=0; int dp[50][50]; void dfs(int x,int y) { if (vis[x][y]) { return; } if (grid[x][y]==0) return; vis[x][y]=true; cnt++; if(y<c-1&&w>=grid[x][y+1]&&!vis[x][y+1]){ dfs(x,y+1); } } 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; memset(dp,-1,sizeof dp); bool test=false; 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; } } 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) { cin>>grid[i][j]; } } for (int i = 0; i < r; ++i) { for (int j = 0; j < c; ++j) { if (grid[i][j]==0) continue; if (vis[i][j]) continue; if (j>0&&grid[i][j]>grid[i][j-1]) continue; cnt=0; dfs(i,j); int cur=cnt; //cout <<cur<<endl; if (cur<ans){ ans=cur; time=cur; }else if(cur==ans) time+=ans; }//cout <<endl; } cout << ans <<endl; cout << time<<endl; }

Compilation message (stderr)

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