답안 #308949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
308949 2020-10-02T11:10:05 Z Hemimor Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
39 ms 6272 KB
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <random>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[8]={-1,0,1,0,1,1,-1,-1},dy[8]={0,1,0,-1,1,-1,1,-1};

vi vin(int n,int d=0){
	vi a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]-=d;
	}
	return a;
}

vl vlin(int n,int d=0){
	vl a(n);
	for(auto &i:a){
		cin>>i;
		i-=d;
	}
	return a;
}

vvi vvin(int n,int m){
	vvi a(n,vi(m));
	for(int i=0;i<n;i++) for(auto &j:a[i]) cin>>j;
	return a;
}

vvi gin(int n,int m,int d=1){
	vvi g(n);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u-=d,v-=d;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	return g;
}

void vout(vi a){
	int n=a.size();
	cout<<n<<" :";
	for(auto i:a) cout<<' '<<i;
	cout<<endl;
}

void vvout(vvi a){
	int n=a.size();
	for(int i=0;i<n;i++) vout(a[i]);
}

bool ingrid(int x,int y,int n,int m){
	return 0<=x&&x<n&&0<=y&&y<m;
}

int readInt() {
    int x=0;
	char ch=getchar_unlocked();
	bool s=1;
    while(ch<'0'||ch>'9'){if(ch=='-')s=0;ch=getchar_unlocked();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar_unlocked();}
    return s?x:-x;
}

int h,w,d,m;

int main(){
	cin>>h>>w>>d>>m;
	vs a(h);
	vvi b(h+1,vi(w+1));
	for(auto &i:a) cin>>i;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(a[i][j]=='S'){
		int x=max(i-d,0),y=max(j-d,0),X=min(h,i+d+1),Y=min(w,j+d+1);
		b[x][y]++;
		b[x][Y]--;
		b[X][y]--;
		b[X][Y]++;
	}
	int t=0;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		if(i) b[i][j]+=b[i-1][j];
		if(j) b[i][j]+=b[i][j-1];
		if(i&&j) b[i][j]-=b[i-1][j-1];
		if(a[i][j]=='M'&&b[i][j]>=m) t++;
	}
	cout<<t<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1536 KB Output is correct
2 Correct 12 ms 1536 KB Output is correct
3 Correct 16 ms 2048 KB Output is correct
4 Correct 13 ms 1792 KB Output is correct
5 Correct 13 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 6272 KB Output is correct
2 Correct 31 ms 6272 KB Output is correct
3 Correct 32 ms 6228 KB Output is correct
4 Correct 34 ms 6272 KB Output is correct
5 Correct 32 ms 6236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 13 ms 1536 KB Output is correct
17 Correct 12 ms 1536 KB Output is correct
18 Correct 16 ms 2048 KB Output is correct
19 Correct 13 ms 1792 KB Output is correct
20 Correct 13 ms 1664 KB Output is correct
21 Correct 34 ms 6272 KB Output is correct
22 Correct 31 ms 6272 KB Output is correct
23 Correct 32 ms 6228 KB Output is correct
24 Correct 34 ms 6272 KB Output is correct
25 Correct 32 ms 6236 KB Output is correct
26 Correct 39 ms 5504 KB Output is correct
27 Correct 35 ms 3712 KB Output is correct
28 Correct 33 ms 3320 KB Output is correct
29 Correct 31 ms 3456 KB Output is correct
30 Correct 37 ms 5116 KB Output is correct