# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
570346 | urd05 | Virus Experiment (JOI19_virus) | C++17 | 58 ms | 11508 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
}
if (lmx==m*2) {
lmx=1e9+7;
}
else if (rmx==m*2) {
rmx=1e9+7;
}
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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |