제출 #921581

#제출 시각아이디문제언어결과실행 시간메모리
921581vjudge1Collecting Mushrooms (NOI18_collectmushrooms)C++17
79 / 100
2061 ms31468 KiB
#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]; void solve(){ cin>>n>>m>>k>>x; int ans=0; char a[n+2][m+2]; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...