Submission #681099

# Submission time Handle Problem Language Result Execution time Memory
681099 2023-01-12T10:57:25 Z Cross_Ratio Nuclearia (CEOI15_nuclearia) C++14
21 / 100
1000 ms 277324 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;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 1078 ms 274300 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 274300 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 316 ms 39836 KB Output is correct
2 Correct 69 ms 3560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 250 ms 39596 KB Output is correct
2 Correct 70 ms 3612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 654 ms 277324 KB Output is correct
2 Correct 66 ms 3916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 113288 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 377 ms 42688 KB Output is correct
2 Correct 64 ms 3772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 632 ms 58404 KB Output is correct
2 Correct 61 ms 3532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1103 ms 274292 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 274224 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 39892 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 39688 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 40460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 39892 KB Time limit exceeded
2 Halted 0 ms 0 KB -