ios_base::sync_with_stdio(0);
in your code. My
#include <cstdio> #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); int n, m, k, row[2005]={0}, col[2005]={0}, ans=0; char ch; cin>>n>>m>>k; for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) { cin>>ch; if(ch=='.') { row[i]++; col[j]++; } else if(ch=='*'){ row[i]=0; col[j]=0; } if(row[i]>=k) ans++; if(col[j]>=k) ans++; } if(k==1) ans/=2; cout<<ans; return 0; }
code passed but similar C++ code got TLE without ios base sync stdio. That is my 2 satoshis(cents :) for you.
No comments:
Post a Comment