Submission #39495

# Submission time Handle Problem Language Result Execution time Memory
39495 2018-01-16T02:49:16 Z funcsr Nuclearia (CEOI15_nuclearia) C++14
19 / 100
1000 ms 82124 KB
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define uniq(x) x.erase(unique(all(x)), x.end())
inline int abs(int x) {
  if (x < 0) return -x;
  return x;
}

int W, H, N, Q;
vector<long long> A[2500000];

int main() {
  scanf("%d %d %d", &W, &H, &N);
  assert(W*H*N <= 1e8);
  //cout<<"W="<<W<<",H="<<H<<", N="<<N<<"\n";
  rep(y, H) A[y].resize(W, 0);
  rep(i, N) {
    int x, y, a, b;
    scanf("%d %d %d %d", &x, &y, &a, &b);
    x--, y--;
    rep(xx, W) rep(yy, H) {
      int dist = max(abs(xx-x), abs(y-yy));
      A[yy][xx] += max(0LL, a-1LL*b*dist);
    }
  }
  /*
  rep(y, H) {
    rep(x, W) cout << A[x][y] << " ";
    cout << "\n";
  }
  */
  rep(y, H) rep(x, W-1) A[y][x+1] += A[y][x];
  rep(y, H-1) rep(x, W) A[y+1][x] += A[y][x];
  scanf("%d", &Q);
  rep(i, Q) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    x1--, y1--, x2--, y2--;
    long long s = A[y2][x2];
    if (x1 > 0) s -= A[y2][x1-1];
    if (y1 > 0) s -= A[y1-1][x2];
    if (x1 > 0 && y1 > 0) s += A[y1-1][x1-1];
    long long q = 1LL*(x2-x1+1)*(y2-y1+1);
    //cout<<s<<"/"<<q<<"\n";
    printf("%lld\n", ((2LL*s/q)+1)/2);
  }
  return 0;
}

Compilation message

nuclearia.cpp: In function 'int main()':
nuclearia.cpp:20:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &W, &H, &N);
                                ^
nuclearia.cpp:26:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d %d", &x, &y, &a, &b);
                                         ^
nuclearia.cpp:41:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &Q);
                  ^
nuclearia.cpp:44:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
                                             ^
# Verdict Execution time Memory Grader output
1 Correct 486 ms 80140 KB Output is correct
2 Correct 123 ms 60608 KB Output is correct
3 Correct 99 ms 60608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 439 ms 80140 KB Output is correct
2 Correct 153 ms 60608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 80144 KB Execution timed out
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 82124 KB Execution timed out
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 343 ms 80140 KB Output is correct
2 Correct 156 ms 60608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 609 ms 68424 KB Output is correct
2 Correct 139 ms 60608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 80276 KB Execution timed out
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 546 ms 68424 KB Output is correct
2 Correct 116 ms 60608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 60612 KB Execution killed because of forbidden syscall gettid (186)
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 60612 KB Execution killed because of forbidden syscall gettid (186)
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 60612 KB Execution killed because of forbidden syscall gettid (186)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 60612 KB Execution killed because of forbidden syscall gettid (186)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 60612 KB Execution killed because of forbidden syscall gettid (186)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 60612 KB Execution killed because of forbidden syscall gettid (186)
2 Halted 0 ms 0 KB -