답안 #341125

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341125 2020-12-29T03:23:57 Z beksultan04 UFO (IZhO14_ufo) C++14
30 / 100
2000 ms 9068 KB
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
const int N = 1e6+12,INF=1e9+7;


main(){
    int n,m,i,j,r,t,p,mx=0;
    vector <vector <int> > q;
    scan3(n,m,r)
    scan2(t,p)
    q.resize(n+1);
    for (i=0;i<=n;++i){
        q[i].resize(m+1);
        for (j=0;j<=m;++j){
            q[i][j]=0;
        }
    }
    for (i=1;i<=n;++i){
        for (j=1;j<=m;++j){
            scan1(q[i][j])
        }
    }
    while (t--){
        char ch;
        int x,y;
        cin>>ch>>x>>y;
        if (ch == 'N'){
            int kanca = r;
            i=1;
            while (kanca > 0 && i <= n){
                if (q[i][x] >= y){
                    q[i][x]--;
                    kanca--;
                }
                i++;
            }
        }
        if (ch == 'E'){

            int kanca = r;
            i=m;
            while (kanca > 0 && i >0 ){
                if (q[x][i] >= y){
                    q[x][i]--;
                    kanca--;
                }
                i--;
            }
        }
        if (ch == 'S'){

            int kanca = r;
            i=n;
            while (kanca > 0 && i > 0){
                if (q[i][x] >= y){
                    q[i][x]--;
                    kanca--;
                }
                i--;
            }
        }
        if (ch == 'W'){

            int kanca = r;
            i=1;
            while (kanca > 0 && i <=m ){
                if (q[x][i] >= y){
                    q[x][i]--;
                    kanca--;
                }
                i++;
            }
        }
    }
    for (i=1;i<=n;++i){
        for (j=1;j<=m;++j){
            q[i][j] = q[i-1][j]+q[i][j-1]-q[i-1][j-1]+q[i][j];
        }
    }
    for (i=1;i<=n;++i){
        for (j=1;j<=m;++j){
            int ans=0,x=i,y=j;
            ans+=q[x][y];
            ans+=q[max(x-p,0)][max(y-p,0)];
            ans-=q[max(x-p,0)][y];
            ans-=q[x][max(y-p,0)];
            mx = max(ans,mx);

        }
    }
    cout <<mx;
}

Compilation message

ufo.cpp:26:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   26 | main(){
      |      ^
ufo.cpp: In function 'int main()':
ufo.cpp:16:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 | #define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~
ufo.cpp:29:5: note: in expansion of macro 'scan3'
   29 |     scan3(n,m,r)
      |     ^~~~~
ufo.cpp:15:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 | #define scan2(a,b) scanf("%d %d",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~
ufo.cpp:30:5: note: in expansion of macro 'scan2'
   30 |     scan2(t,p)
      |     ^~~~~
ufo.cpp:14:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 | #define scan1(a) scanf("%d",&a);
      |                  ~~~~~^~~~~~~~~
ufo.cpp:40:13: note: in expansion of macro 'scan1'
   40 |             scan1(q[i][j])
      |             ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 8 ms 364 KB Output is correct
5 Correct 36 ms 492 KB Output is correct
6 Correct 98 ms 2284 KB Output is correct
7 Execution timed out 2086 ms 4588 KB Time limit exceeded
8 Execution timed out 2091 ms 4588 KB Time limit exceeded
9 Execution timed out 2056 ms 4460 KB Time limit exceeded
10 Execution timed out 2096 ms 4588 KB Time limit exceeded
11 Execution timed out 2055 ms 4588 KB Time limit exceeded
12 Execution timed out 2085 ms 4588 KB Time limit exceeded
13 Execution timed out 2093 ms 9068 KB Time limit exceeded
14 Execution timed out 2085 ms 4588 KB Time limit exceeded
15 Execution timed out 2084 ms 4588 KB Time limit exceeded
16 Execution timed out 2097 ms 4588 KB Time limit exceeded
17 Execution timed out 2085 ms 8940 KB Time limit exceeded
18 Execution timed out 2099 ms 8812 KB Time limit exceeded
19 Execution timed out 2048 ms 4972 KB Time limit exceeded
20 Execution timed out 2060 ms 8172 KB Time limit exceeded