Submission #570332

#TimeUsernameProblemLanguageResultExecution timeMemory
570332urd05Virus Experiment (JOI19_virus)C++17
0 / 100
72 ms11388 KiB
#include <bits/stdc++.h> using namespace std; int arr[800][800]; char str[200001]; int rdp[800][800]; int ldp[800][800]; int m,r,c; int main() { scanf("%d %d %d",&m,&r,&c); scanf("%s",str); for(int i=0;i<r;i++) { for(int j=0;j<c;j++) { scanf("%d",&arr[i][j]); } } for(int i=m;i<m*2;i++) { str[i]=str[i-m]; } int lmx=0; int rmx=0; int le=0; int ri=0; for(int i=0;i<m*2;i++) { if (str[i]=='E') { le++; ri=0; } else { ri++; le=0; } lmx=max(lmx,le); rmx=max(rmx,ri); } for(int i=0;i<r;i++) { ldp[i][0]=0; for(int j=1;j<c;j++) { if (arr[i][j-1]!=0&&arr[i][j-1]<=lmx) { ldp[i][j]=ldp[i][j-1]; } else { ldp[i][j]=j; } } rdp[i][c-1]=c-1; for(int j=c-2;j>=0;j--) { if (arr[i][j+1]!=0&&arr[i][j+1]<=rmx) { rdp[i][j]=rdp[i][j+1]; } else { rdp[i][j]=j; } } } int cnt=0; int ret=1e9; for(int i=0;i<r;i++) { for(int j=0;j<c;j++) { if (arr[i][j]!=0) { int val=rdp[i][j]-ldp[i][j]+1; if (val<ret) { cnt=1; ret=val; } else if (val==ret) { cnt++; } } } } printf("%d\n%d",ret,cnt); return 0; }

Compilation message (stderr)

virus.cpp: In function 'int main()':
virus.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d %d %d",&m,&r,&c);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
virus.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%s",str);
      |     ~~~~~^~~~~~~~~~
virus.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |             scanf("%d",&arr[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...