Submission #1022274

# Submission time Handle Problem Language Result Execution time Memory
1022274 2024-07-13T11:48:03 Z vjudge1 Nuclearia (CEOI15_nuclearia) C++17
15 / 100
1000 ms 61336 KB
#include <iostream>
//#include <bits/stdc++.h>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef vector<ll> vi;
typedef vector<bool> vb;
const ll mm = 1000000007;
const int maxn = 2e5 + 1;

ll near(ll a, ll b) {
    double a1 = a, b1 = b;
    double d = a1 / b1;
    if (d - floor(d) < 0.5) {
        return floor(d);
    }
    else return ceil(d);
}


int main() {                           
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    ll w, h; cin >> w >> h;            //radimo sucaj h=1
    vector<vi> p(h, vi(w));
    ll n; cin >> n;
    ll xn, yn, a, b;
    for (int i = 0; i < n; i++) {
        cin >> xn >> yn >> a >> b;
        --yn, --xn;

        ll maxd = (a / b);

        ll dis, xc = xn - maxd;
        for (xc; xc <= xn + maxd; xc++) {

            if (xc < 0) xc=-1;
            else if (xc > w - 1) xc = xn + maxd + 1;
            else {
                dis = abs(xc - xn);
                ll k = a - b * dis;
                if (k < 0) k = 0;
                p[0][xc] += k;
                    
            }
        }
    }

    vector<vi> dp(h, vi(w));

    dp[0][0] = p[0][0];

    for (int j = 1; j < w; j++) {
        dp[0][j] = p[0][j] + dp[0][j - 1];
    }

    for (int i = 1; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (j == 0) {
                dp[i][j] = p[i][j] + dp[i - 1][j];
            }
            else {
                dp[i][j] = p[i][j] + dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
            }
        }
    }



    ll q; cin >> q;
    while (q--) {
        ll x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2;
        x1--; x2--; y1--; y2--;
        ll A = (y2 - y1 + 1) * (x2 - x1 + 1);
        ll S = 0;
        S += dp[y2][x2];
        if (x1 > 0 and y1 > 0) {
            S -= dp[y2][x1 - 1];
            S -= dp[y1 - 1][x2];
            S += dp[y1 - 1][x1 - 1];
        }
        else if (x1 == 0 and y1 == 0) {

        }
        else if (x1 == 0) {
            S -= dp[y1 - 1][x2];
        }
        else if (y1 == 0) {
            S -= dp[y2][x1 - 1];
        }

        cout << near(S, A) << endl;


    }


    return 0;

}

Compilation message

nuclearia.cpp: In function 'int main()':
nuclearia.cpp:45:14: warning: statement has no effect [-Wunused-value]
   45 |         for (xc; xc <= xn + maxd; xc++) {
      |              ^~
# Verdict Execution time Memory Grader output
1 Correct 276 ms 59100 KB Output is correct
2 Correct 272 ms 2640 KB Output is correct
3 Correct 258 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 209 ms 59104 KB Output is correct
2 Correct 288 ms 2912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 39672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 49244 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 437 ms 61336 KB Output is correct
2 Correct 266 ms 2916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 438 ms 26216 KB Output is correct
2 Correct 304 ms 2616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 309 ms 40268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 380 ms 21736 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 39516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1031 ms 39512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 405 ms 46816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 427 ms 44400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 489 ms 48004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 22356 KB Time limit exceeded
2 Halted 0 ms 0 KB -