제출 #1246395

#제출 시각아이디문제언어결과실행 시간메모리
1246395CyberCow모자이크 (IOI24_mosaic)C++20
12 / 100
78 ms23880 KiB
#include "mosaic.h" #include <bits/stdc++.h> using namespace std; using ll = long long; int a[5][200005]; int pref[5][200005]; int a1[200005][5]; int pref1[200005][5]; int gum(int x, int x1, int y, int y1) { int arj = pref[x1][y1]; if(x)arj -= pref[x - 1][y1]; if(y)arj-=pref[x1][y - 1]; if(x && y)arj += pref[x - 1][y - 1]; return arj; } vector<long long> mosaic(vector<int> X, vector<int> Y, vector<int> T, vector<int> B, vector<int> L, vector<int> R) { int Q = (int)T.size(); vector<long long> C(Q, 0); pref[0][0] = X[0]; pref1[0][0] = X[0]; a[0][0] = X[0]; a1[0][0] = X[0]; for (int i = 1; i < X.size(); i++) { a[0][i] = X[i]; pref[0][i] = pref[0][i - 1] + a[0][i]; if(i <= 2) { a1[0][i] = X[i]; pref1[0][i] = pref1[0][i - 1] + a1[0][i]; } } for (int i = 1; i < Y.size(); i++) { a1[i][0] = Y[i]; pref1[i][0] = pref1[i - 1][0] + a1[i][0]; if(i <= 2) { a[i][0] = Y[i]; pref[i][0] = pref[i - 1][0] + a[i][0]; } } int n = X.size(); for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { if(i > 2 && j > 2)break; if(i <= 2) { if(a[i - 1][j] == 0 && a[i][j - 1] == 0) { a[i][j] = 1; } pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + a[i][j]; } if(j <= 2) { if(a1[i - 1][j] == 0 && a1[i][j - 1] == 0) { a1[i][j] = 1; } pref1[i][j] = pref1[i - 1][j] + pref1[i][j - 1] - pref1[i - 1][j - 1] + a1[i][j]; } } } for (int i = 0; i < Q; i++) { C[i] = gum(T[i], B[i], L[i], R[i]); } return C; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...