183732025-10-21 14:08:56ubormaciTóparti sétacpp17Elfogadva 100/10012ms1500 KiB
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <array>
#include <string>
#include <cstdio>
#include <iterator>
#include <unordered_set>
#include <cstdint>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <fstream>
using namespace std;

#pragma GCC optimize("O2")

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#ifdef LOCAL
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

/*

notes:

int64_t
stoi(string s) -> string to int
to_string() -> int (or else) to string

vector declaration:
vector<ll> v(n, 0)
vector<vector<ll>> v(n, vector<ll>(n, 0));

{if statement} ? {truth value} : {false value}

set lower bound/upper bound:
 	// . . . m1 . . . d . . . . m2
    auto m1_it = b.lower_bound(d);
    advance(m1_it, -1);
    m1 = *m1_it;
	m2 = *b.upper_bound(d);

#ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif

constexpr auto lcm(auto x, auto... xs)
{
	return ((x = std::lcm(x, xs)), ...);
}

std::gcd(int a, int b)

*/

typedef long long ll;

void solve() {
	ll n, m;
	cin >> n >> m;
	vector<string> v(n, "");
	for(ll i = 0; i < n; i++) {
		cin >> v[i];
	}

	ll s = 0;
	for(ll i = 0; i < n; i++) {
		for(ll j = 0; j < m; j++) {
			if(v[i][j] == '#') {
				if(v[i][j-1] != '#') {
					s++;
				}
				if(v[i][j+1] != '#') {
					s++;
				}
				if(v[i-1][j] != '#') {
					s++;
				}
				if(v[i+1][j] != '#') {
					s++;
				}
			}
		}
	}
	cout << s;
}

int main()
{
	std::ios_base::sync_with_stdio(false);

	solve();

	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
subtask10/0
1Elfogadva1ms500 KiB
2Elfogadva1ms316 KiB
subtask250/50
3Elfogadva1ms316 KiB
4Elfogadva1ms316 KiB
5Elfogadva4ms1332 KiB
subtask330/30
6Elfogadva1ms316 KiB
7Elfogadva1ms316 KiB
8Elfogadva1ms316 KiB
9Elfogadva1ms316 KiB
subtask420/20
10Elfogadva1ms316 KiB
11Elfogadva1ms316 KiB
12Elfogadva1ms316 KiB
13Elfogadva1ms316 KiB
14Elfogadva4ms1332 KiB
15Elfogadva1ms316 KiB
16Elfogadva1ms316 KiB
17Elfogadva1ms316 KiB
18Elfogadva1ms316 KiB
19Elfogadva12ms1252 KiB
20Elfogadva12ms1500 KiB
21Elfogadva4ms1336 KiB
22Elfogadva4ms1332 KiB