Submission #681101

# Submission time Handle Problem Language Result Execution time Memory
681101 2023-01-12T10:59:18 Z Cross_Ratio Nuclearia (CEOI15_nuclearia) C++14
21 / 100
1000 ms 276556 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
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(register 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:34:76: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
   34 |             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:43:77: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
   43 |         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 1075 ms 274304 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1103 ms 274244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 268 ms 39764 KB Output is correct
2 Correct 59 ms 2660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 236 ms 39600 KB Output is correct
2 Correct 90 ms 2692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 618 ms 276556 KB Output is correct
2 Correct 64 ms 3056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1058 ms 112256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 321 ms 41872 KB Output is correct
2 Correct 78 ms 2888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 606 ms 57432 KB Output is correct
2 Correct 55 ms 2676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 274280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 274224 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1043 ms 39844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 39656 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 40408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 39840 KB Time limit exceeded
2 Halted 0 ms 0 KB -