# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
921817 | 2024-02-04T10:45:33 Z | vjudge1 | Collecting Mushrooms (NOI18_collectmushrooms) | C++17 | 2000 ms | 15660 KB |
#include <bits/stdc++.h> #define ll long long #define pb push_back using namespace std; void solve(){ ll a,b,d,k,t; cin>>a>>b>>d>>k; t=a; if(a==1){ char c[b+1]; ll ans=0; map<ll,ll>mp; vector<ll>v; for(ll i=1;i<=b;i++){ cin>>c[i]; if(c[i]=='M'){ v.pb(i); } } for(ll i=1;i<=b;i++){ if(c[i]=='S'){ for(ll j=i;j<=min(i+d,b);j++){ mp[j]++; } for(ll j=i-1;j>=max(0ll,i-d);j--){ mp[j]++; } } } for(ll i=0;i<v.size();i++){ if(mp[v[i]]>=k){ ans++; } } cout<<ans; } else { vector<pair<ll,ll> >v,l; char c[a+1][b+1]; for(ll i=1;i<=a;i++){ for(ll j=1;j<=b;j++){ cin>>c[i][j]; if(c[i][j]=='S'){ v.pb({i,j}); } else if(c[i][j]=='M'){ l.pb({i,j}); } } } //sort(v.begin(),v.end()); ll ans=0,count=0; for(ll i=0;i<l.size();i++){ ans=0; for(ll j=0;j<v.size();j++){ ll res=0; res=max(abs(v[j].first-l[i].first),abs(v[j].second-l[i].second)); if(res<=d){ ans++; } if(ans>=k){ count++; break; } } ans=0; } cout<<count; } } int main() { ios_base::sync_with_stdio(0),cin.tie(0); ll t=1,i=1; //cin>>t; while(t--){ //cout<<"Case "; //cout<<i<<':'<<"\n"; //i++; solve(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 604 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 604 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 13 ms | 604 KB | Output is correct |
9 | Correct | 2 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 3 ms | 348 KB | Output is correct |
3 | Correct | 6 ms | 748 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 604 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 604 KB | Output is correct |
2 | Correct | 2 ms | 604 KB | Output is correct |
3 | Correct | 3 ms | 600 KB | Output is correct |
4 | Correct | 3 ms | 604 KB | Output is correct |
5 | Correct | 2 ms | 604 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2083 ms | 15660 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 604 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 13 ms | 604 KB | Output is correct |
9 | Correct | 2 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 3 ms | 348 KB | Output is correct |
13 | Correct | 6 ms | 748 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 604 KB | Output is correct |
16 | Correct | 2 ms | 604 KB | Output is correct |
17 | Correct | 2 ms | 604 KB | Output is correct |
18 | Correct | 3 ms | 600 KB | Output is correct |
19 | Correct | 3 ms | 604 KB | Output is correct |
20 | Correct | 2 ms | 604 KB | Output is correct |
21 | Execution timed out | 2083 ms | 15660 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |