이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define F first
#define S second
#define ent '\n'
#define int long long
#define pb push_back
typedef long double ld;
typedef long long ll;
using namespace std;
const int maxn = 1e6+12;
const int T = 0;
const int mod = 1e9+7;
int n,m,k,x,y,l,r;
int b[maxn],p[maxn],pref[maxn],fact[maxn];
char a[2222][2222];
void solve(){
cin>>n>>m>>k>>x;
int ans=0;
vector<pair<int,int>>v;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
if(a[i][j]=='S'){
v.pb({i,j});
}
}
}
map<int,int>mp;
if(n==1){
int cnt=0,l=1,r=m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(j-l > k){
if(a[i][l]=='S')cnt--;
l++;
}
if(a[i][j]=='M'){
mp[j]=cnt;
}
if(a[i][j]=='S')cnt++;
}
cnt=0;
for(int j=m;j>=1;j--){
if(r-j > k){
if(a[i][r]=='S')cnt--;
r--;
}
if(a[i][j]=='M'){
if(mp[j]+cnt >= x)ans++;
}
if(a[i][j]=='S')cnt++;
}
}
cout<<ans;
return;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]=='M'){
int cal=0;
for(int u=0;u<v.size();u++){
if(max(abs(i-v[u].F) , abs(j-v[u].S)) <= k)cal++;
}
if(cal>=x)ans++;
}
}
}
cout<<ans;
}
//BEKSULTAN TOP
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
if(T)cin>>t;
while(t--)solve();
}
컴파일 시 표준 에러 (stderr) 메시지
mushrooms.cpp: In function 'void solve()':
mushrooms.cpp:65:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for(int u=0;u<v.size();u++){
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |