제출 #431985

#제출 시각아이디문제언어결과실행 시간메모리
431985ScarletS바이러스 (JOI19_virus)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #define ll long long #define sz(x) (int)(x).size() using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int k,n,m,e=0,w=0,a1,a2=0,l,r; cin>>k>>n>>m; string s; cin>>s; int a[n][m]; a1=n*m; for (int i=0;i<n;++i) for (int j=0;j<m;++j) cin>>a[i][j]; vector<int> v={1}; for (int i=1;i<k;++i) { if (s[i]==s[i-1]) ++v.back(); else v.push_back(1); if (s[i]=='E') e=max(e,v.back()); else w=max(w,v.back()); } if (e==0||w==0) { cout<<1; return 0; } if (s[0]==s[k-1]) { if (s[0]=='E') e=max(e,v[0]+v.back()); else w=max(w,v[0]+v.back()); } for (int i=0;i<n;++i) for (int j=0;j<m;++j) if (a[i][j]!=0) { l=j;r=j; while (0<l&&a[i][l-1]<=e&&a[i][l-1]!=0) --l; while (r+1<n&&a[i][r+1]<=w&&a[i][r+1]!=0) ++r; if (r-l+1<a1) { a1=r-l+1; a2=1; } else if (r-l+1==a1) ++a2; } cout<<a1<<"\n"<<a2; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...