Submission #1014556

#TimeUsernameProblemLanguageResultExecution timeMemory
1014556ReLiceVirus Experiment (JOI19_virus)C++17
0 / 100
38 ms20516 KiB
#include <bits/stdc++.h> #define ll long long #define str string #define ins insert #define ld long double #define pb push_back #define pf push_front #define pof pop_front() #define pob pop_back() #define lb lower_bound #define ub upper_bound #define endl "\n" #define fr first #define sc second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define sz size() #define vll vector<ll> #define bc back() #define arr array #define pll vector<pair<ll,ll>> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> template<class S,class T> bool chmin(S &a,const T &b) { return a>b?(a=b)==b:false; } template<class S,class T> bool chmax(S &a,const T &b) { return a<b?(a=b)==b:false; } //void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf=1e18; const ll mod=1e9+7; const ll N=1e3+7; const ld eps=1e-9; ll a[N][N]; ll w[N][N],e[N][N]; void solve(){ ll i,j,k; ll n,r,c; cin>>n>>r>>c; deque<char> dq(n); map<char,ll> mp; ll cc=0; for(i=0;i<n;i++){ cin>>dq[i]; if(mp[dq[i]]==0)cc++; mp[dq[i]]++; } for(i=1;i<=r;i++){ for(j=1;j<=c;j++){ cin>>a[i][j]; } } ll ans=0; if(cc==1){ for(i=1;i<=r;i++){ for(j=1;j<=c;j++){ if(dq[0]=='W' && a[i][j-1]==0)ans++; if(dq[0]=='E' && a[i][j+1]==0)ans++; } } cout<<1<<endl; cout<<ans<<endl; return; } while(dq[0]==dq.bc){ dq.pb(dq[0]); dq.pof; } ll cnt=0; ll W=0,E=0; for(i=0;i<n;i++){ if(i==0 || dq[i]!=dq[i-1]){ cnt=0; }cnt++; if(dq[i]=='W')chmax(W,cnt); if(dq[i]=='E')chmax(E,cnt); } ll mn=inf; map<ll,ll> mp2;/* for(auto i : dq) cout<<i;cout<<endl; cout<<W<<' '<<E<<endl;*/ for(i=1;i<=r;i++){ ll cnt=0; for(j=1;j<=c;j++){ if(a[i][j]==0 || a[i][j]>W) cnt=0; else cnt++; w[i][j]=cnt; } cnt=0; for(j=c;j>0;j--){ if(a[i][j]==0 || a[i][j]>E) cnt=0; else cnt++; e[i][j]=cnt; } for(j=1;j<=c;j++){ if(a[i][j]==0) continue; chmin(mn,e[i][j+1]+w[i][j-1]+1); mp2[e[i][j+1]+w[i][j-1]+1]++; } }/*cout<<endl; for(i=1;i<=r;i++){ for(j=1;j<=c;j++)cout<<w[i][j]<<' ';cout<<endl; }cout<<endl; for(i=1;i<=r;i++){ for(j=1;j<=c;j++)cout<<e[i][j]<<' ';cout<<endl; }cout<<endl;*/ cout<<mn<<endl; cout<<mp2[mn]<<endl; } signed main(){ start(); ll t=1; //cin>>t; while(t--) solve(); return 0; } /* a<b<c<d a a b b a a a a */

Compilation message (stderr)

virus.cpp: In function 'void solve()':
virus.cpp:49:12: warning: unused variable 'k' [-Wunused-variable]
   49 |     ll i,j,k;
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...