Submission #462273

# Submission time Handle Problem Language Result Execution time Memory
462273 2021-08-10T09:26:02 Z kingfran1907 Nuclearia (CEOI15_nuclearia) C++14
30 / 100
1000 ms 303548 KB
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 3e6+10;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 18;
const int off = 1 << logo;
const int treesiz = off << 1;

int n, q;
int w, h;
vector< llint > niz[maxn];
vector< llint > pref[maxn];

int main() {
	scanf("%d%d", &w, &h);
	for (int i = 0; i < w; i++) 
		for (int j = 0; j < h; j++)
			niz[i].push_back(0);
			
	scanf("%d", &n);
	while (n--) {
		int x, y;
		llint a, b;
		scanf("%d%d%lld%lld", &x, &y, &a, &b); x--, y--;
		
		for (int i = 0; i < w; i++) {
			for (int j = 0; j < h; j++) {
				int dis = max(abs(i - x), abs(j - y));
				llint kol = max(0LL, a - b * dis);
				niz[i][j] += kol;
			}
		}
	}
	
	for (int i = 0; i <= w; i++) {
		for (int j = 0; j <= h; j++) {
			pref[i].push_back(0);
		}
	}
	
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			pref[i + 1][j + 1] = niz[i][j];
			pref[i + 1][j + 1] += pref[i + 1][j];
		}
	}
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			pref[i + 1][j + 1] += pref[i][j + 1];
		}
	}
	
	scanf("%d", &q);
	while (q--) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2); x1--, y1--;
		
		llint sum = pref[x2][y2] - pref[x1][y2] - pref[x2][y1] + pref[x1][y1];
		llint cnt = (llint)(x2 - x1) * (y2 - y1);
		
		llint sol = sum / cnt;
		llint rem = sum % cnt;
		
		if (rem * 2 >= cnt) printf("%lld\n", sol + 1);
		else printf("%lld\n", sol);
	}
	return 0;
}

Compilation message

nuclearia.cpp: In function 'int main()':
nuclearia.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%d%d", &w, &h);
      |  ~~~~~^~~~~~~~~~~~~~~~
nuclearia.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
nuclearia.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   scanf("%d%d%lld%lld", &x, &y, &a, &b); x--, y--;
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nuclearia.cpp:60:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |  scanf("%d", &q);
      |  ~~~~~^~~~~~~~~~
nuclearia.cpp:63:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |   scanf("%d%d%d%d", &x1, &y1, &x2, &y2); x1--, y1--;
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 928 ms 297768 KB Output is correct
2 Correct 177 ms 145668 KB Output is correct
3 Correct 163 ms 144700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 964 ms 297776 KB Output is correct
2 Correct 171 ms 145476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 334 ms 181400 KB Output is correct
2 Correct 161 ms 143556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 334 ms 181980 KB Output is correct
2 Correct 169 ms 143556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 741 ms 303548 KB Output is correct
2 Correct 177 ms 146244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 869 ms 209600 KB Output is correct
2 Correct 170 ms 145524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 450 ms 186828 KB Output is correct
2 Correct 173 ms 143820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 649 ms 186116 KB Output is correct
2 Correct 168 ms 145220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 219376 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 219348 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 161288 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 161200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 161840 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 161220 KB Time limit exceeded
2 Halted 0 ms 0 KB -