Submission #758995

#TimeUsernameProblemLanguageResultExecution timeMemory
758995kirakosyanDijamant (COCI22_dijamant)C++17
0 / 70
1 ms468 KiB
#include <iostream> #include <vector> #include <algorithm> #include <set> #include <cmath> #include <map> #include <string> #include <ios> #include <iomanip> #include <deque> #include <queue> #include <list> #include <stack> #define FASTIO ios_base::sync_with_stdio(0); cin.tie(NULL); using ll = long long; using namespace std; void solve(){ int n,m; cin >> n >> m; vector<string>v(n); vector<vector<int>>a(n,vector<int>(m)); vector<vector<int>>b(n,vector<int>(m)); vector<vector<int>>c(n,vector<int>(m)); vector<vector<int>>d(n,vector<int>(m)); vector<vector<int>>pref(n,vector<int>(m)); for(int i=0;i<n;i++){ cin >> v[i]; } for(int i=0;i<n;i++){ if(v[i][0]=='#'){ pref[i][0]=1; } for(int j=1;j<m;j++){ if(v[i][j]=='#'){ pref[i][j]=pref[i][j-1]+1; } else pref[i][j]=pref[i][j-1]; } } // 7 10 // .....#... // ....#.#.. // ...#...#. // ..#.....# // ...#...#. // ....#.#.. // .....#... for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(j!=0&&i!=n-1&&j!=m-1){ if(v[i+1][j-1]=='#'&&v[i+1][j+1]=='#'&&v[i+1][j]=='.'&&v[i][j]=='#'){ a[i+1][j-1]=1; b[i+1][j+1]=1; } } if(j!=0&&i!=0&&j!=m-1){ if(v[i-1][j-1]=='#'&&v[i-1][j+1]=='#'&&v[i-1][j]=='.'&&v[i][j]=='#'){ c[i-1][j-1]=1; d[i-1][j+1]=1; } } } } for (int i=0;i<n;i++){ int arajin=-1,erkrord=-1,cnt=0; for(int j=0;j<m;j++){ if(v[i][j]=='#'&&cnt==0) { cnt++; arajin=j; } else if(v[i][j]=='#'&&cnt==1) { if(i>=1&&a[i-1][arajin+1]==1&&b[i-1][j-1]==1&&(pref[i-1][j-1]-pref[i-1][arajin])==0){ a[i][arajin]=1; b[i][j]=1; } if(i<=n-2&&c[i+1][arajin+1]==1&&d[i+1][j-1]==1&&(pref[i+1][j-1]-pref[i+1][arajin])){ c[i][arajin]=1; d[i][j]=1; } arajin=j; } } } for (int i=n-1;i>=0;i--){ int arajin=-1,erkrord=-1,cnt=0; for(int j=0;j<m;j++){ if(v[i][j]=='#'&&cnt==0) { cnt++; arajin=j; } else if(v[i][j]=='#'&&cnt==1) { if(i<=n-2&&c[i+1][arajin+1]==1&&d[i+1][j-1]==1){ c[i][arajin]=1; d[i][j]=1; } arajin=j; } } } // for(int i=0;i<n;i++){ // for(int j=0;j<m;j++){ // cout<<a[i][j]<<" "; // } // cout<<endl; // } // cout<<endl; // for(int i=0;i<n;i++){ // for(int j=0;j<m;j++){ // cout<<b[i][j]<<" "; // } // cout<<endl; // } // cout<<endl; // for(int i=0;i<n;i++){ // for(int j=0;j<m;j++){ // cout<<c[i][j]<<" "; // } // cout<<endl; // } // cout<<endl; // for(int i=0;i<n;i++){ // for(int j=0;j<m;j++){ // cout<<d[i][j]<<" "; // } // cout<<endl; // } // cout<<endl; int ans=0; for(int i=0;i<n;i++){ int cnt=0; int arajin=-1,erkrord=-1; for(int j=0;j<m;j++){ if(v[i][j]=='#'&&cnt==0) { cnt++; arajin=j; } else if(v[i][j]=='#'&&cnt==1) { // cout<<i<<" "<<j<<" "<<arajin<<endl;; // cout<<"HECHSTEXKMDNIAHSES"<<endl; if(a[i][arajin]==1&&c[i][arajin]==1&&b[i][j]==1&&d[i][j]==1){ ans++; } arajin=j; } } } cout<<ans<<endl; } signed main() { FASTIO ll t=1; //cin >> t; while (t--) { solve(); } }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:66:27: warning: unused variable 'erkrord' [-Wunused-variable]
   66 |             int arajin=-1,erkrord=-1,cnt=0;
      |                           ^~~~~~~
Main.cpp:86:27: warning: unused variable 'erkrord' [-Wunused-variable]
   86 |             int arajin=-1,erkrord=-1,cnt=0;
      |                           ^~~~~~~
Main.cpp:134:31: warning: unused variable 'erkrord' [-Wunused-variable]
  134 |                 int arajin=-1,erkrord=-1;
      |                               ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...