Submission #538569

# Submission time Handle Problem Language Result Execution time Memory
538569 2022-03-17T06:53:12 Z FatihSolak Nuclearia (CEOI15_nuclearia) C++17
42 / 100
1000 ms 244848 KB
    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        #ifdef Local
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
        #endif
        bool swp = 0;
        int w,h;
        scanf("%d %d",&w,&h);
        if(w < h){
            swp = 1;
            swap(w,h);
        }
        long long arr[h+5][2*h+w+5];
        long long pre[h+5][2*h+w+5];
        for(int i=0;i<h+5;i++){
            for(int j = 0;j<2*h+w+5;j++){
                arr[i][j] = pre[i][j] = 0;
            }
        }    
        int n;
        scanf("%d ",&n);
        for(int i=0;i<n;i++){
            int x,y,a,b;
            scanf("%d %d %d %d",&x,&y,&a,&b);
            if(swp)swap(x,y);
            x += 2*h;
            for(int i=1;i<=h;i++){
                int dif = abs(y-i);
                if(dif * b > a)continue;
     
                arr[i][max(1,x-dif+1)] -= b;
                arr[i][max(1,x-(a/b))] += b;
                arr[i][max(1,x-(a/b))] += a - b*(x - max(1,x-(a/b)) + 1);
                arr[i][max(1,x-(a/b)) + 1] -= a - b*(x - max(1,x-(a/b)) + 1);
     
                arr[i][min(w+2*h+1,x+dif+1)] -= b;
                arr[i][min(w+2*h+1,x+(a/b)+1)] += b;
                arr[i][min(w+2*h+1,x+(a/b)+1)] -= a%b;
                arr[i][min(w+2*h+1,x+(a/b)+2)] += a%b;
            }
        }
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w+2*h;j++){
                arr[i][j] += arr[i][j-1];
            }
            for(int j=1;j<=w+2*h;j++){
                arr[i][j] += arr[i][j-1];
                //cout << arr[i][j] << " ";
            }
            //cout << endl;
        }
        for(int i=1;i<=h;i++){
            for(int j=2*h+1;j<=w+2*h;j++){
                pre[i][j] = pre[i-1][j] + pre[i][j-1] - pre[i-1][j-1]+arr[i][j];
            }
        }
        int q;
        scanf("%d",&q);
        while(q--){
            int x1,y1,x2,y2;
            scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
            if(!swp)swap(x1,y1),swap(x2,y2);
            y1 += 2*h;
            y2 += 2*h;
            long double cnt = (x2-x1+1) * (y2 -y1+1);
            long long x = ((pre[x2][y2] - pre[x2][y1-1] - pre[x1 -1][y2] + pre[x1-1][y1-1] + cnt/2)/cnt);
            printf("%lld\n",x);
        }
    }	

Compilation message

nuclearia.cpp: In function 'int main()':
nuclearia.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf("%d %d",&w,&h);
      |         ~~~~~^~~~~~~~~~~~~~~
nuclearia.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         scanf("%d ",&n);
      |         ~~~~~^~~~~~~~~~
nuclearia.cpp:26:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |             scanf("%d %d %d %d",&x,&y,&a,&b);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
nuclearia.cpp:60:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |         scanf("%d",&q);
      |         ~~~~~^~~~~~~~~
nuclearia.cpp:63:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |             scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 179 ms 235120 KB Output is correct
2 Correct 81 ms 4556 KB Output is correct
3 Correct 76 ms 3788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 149 ms 235120 KB Output is correct
2 Correct 92 ms 4612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 47752 KB Output is correct
2 Incorrect 83 ms 4248 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 55 ms 49212 KB Output is correct
2 Correct 90 ms 4604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 263 ms 241008 KB Output is correct
2 Correct 83 ms 5192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 193 ms 100080 KB Output is correct
2 Correct 96 ms 4524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 177 ms 53536 KB Output is correct
2 Incorrect 92 ms 4880 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 152 ms 60812 KB Output is correct
2 Incorrect 102 ms 4284 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 372 ms 244848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 390 ms 244824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 50548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 72672 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 44052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 48468 KB Time limit exceeded
2 Halted 0 ms 0 KB -