# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
827649 | DarkMatter | Emacs (COCI20_emacs) | C++17 | 1 ms | 384 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.
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int>pi;
typedef pair<ll, ll>pl;
typedef vector<pi>vpi;
typedef vector<pl>vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
const long double PI = acos(-1);
const ll oo = 1e18;
const int MOD = 1e9 + 7;
const int N = 2e5 + 7;
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define read(v) for (auto& it : v) scanf("%d", &it);
#define readL(v) for (auto& it : v) scanf("%lld", &it);
#define print(v) for (auto it : v) printf("%d ", it); puts("");
#define printL(v) for (auto it : v) printf("%lld ", it); puts("");
int dr[] = { -1,0 }, dc[] = { 0,-1 };
void solve() {
int n, m, ans = 0;
scanf("%d %d", &n, &m);
vs v(n);
for (auto& it : v)
cin >> it;
vector<vpi> p(n, vpi(m, { -1 ,-1 }));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (v[i][j] == '.')
continue;
bool ok = false;
for (int d = 0; d < 2; d++) {
int nr = i + dr[d], nc = j + dc[d];
if (nr < 0 || nc < 0 || v[nr][nc] == '.')
continue;
p[i][j] = p[nr][nc];
ok = true;
}
if (!ok)
p[i][j] = { i,j }, ans++;
}
}
printf("%d\n", ans);
}
int t = 1;
int main() {
//#ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
//#endif
//scanf("%d", &t);
while (t--) solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |