Submission #681096

# Submission time Handle Problem Language Result Execution time Memory
681096 2023-01-12T10:56:30 Z Cross_Ratio Nuclearia (CEOI15_nuclearia) C++14
4 / 100
1000 ms 276488 KB
#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int>> A, B;
array<long long int, 4> C[200005];
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int W, H;
    cin >> W >> H;
    A.resize(W);
    B.resize(W);
    int i, j;
    for(i=0;i<W+1;i++) {
        A[i].resize(H);
        B[i].resize(H);
    }
    int N;
    cin >> N;
    for(i=0;i<N;i++) {
        cin >> C[i][0] >> C[i][1] >> C[i][2] >> C[i][3];
        C[i][0]--, C[i][1]--;
        for(j=0;j<W;j++) {
            for(int k = 0; k < H; k++) {
                A[j][k] += max(0LL, C[i][2] - max(abs(j-C[i][0]),abs(k-C[i][1])) * C[i][3]);
            }
        }
    }
    for(i=0;i<W;i++) {
        for(j=0;j<H;j++) {
            B[i][j] = (i?B[i-1][j]:0) + (j?B[i][j-1]:0) - ((long long int)i*j?B[i-1][j-1]:0) + A[i][j];
        }
    }
    int Q;
    cin >> Q;
    while(Q--) {
        long long int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;
        long long int val = B[c][d] - (a?B[a-1][d]:0) - (b?B[c][b-1]:0) + (a*b?B[a-1][b-1]:0);
        //cout << val << '\n';
        long long int x = (c-a+1)* (d-b+1);
        long long int y = val / x;
        if(2*(val % x) >= x) y++;
        cout << y << '\n';
    }
}

Compilation message

nuclearia.cpp: In function 'int main()':
nuclearia.cpp:31:76: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
   31 |             B[i][j] = (i?B[i-1][j]:0) + (j?B[i][j-1]:0) - ((long long int)i*j?B[i-1][j-1]:0) + A[i][j];
      |                                                            ~~~~~~~~~~~~~~~~^~
nuclearia.cpp:40:77: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
   40 |         long long int val = B[c][d] - (a?B[a-1][d]:0) - (b?B[c][b-1]:0) + (a*b?B[a-1][b-1]:0);
      |                                                                            ~^~
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 274304 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 274296 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 312 ms 80544 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 56 ms 80032 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 693 ms 276488 KB Output is correct
2 Runtime error 90 ms 3268 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1016 ms 112220 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 47 ms 79912 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 604 ms 57428 KB Output is correct
2 Correct 53 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 274176 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 274244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 39836 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 39640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 40408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1100 ms 39840 KB Time limit exceeded
2 Halted 0 ms 0 KB -