# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1108801 |
2024-11-05T06:29:33 Z |
KasymK |
Mosaic (IOI24_mosaic) |
C++17 |
|
275 ms |
303300 KB |
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 5005;
int v[N][N];
ll p[N][N], par[N];
vector<ll> mosaic(vector<int> X, vector<int> Y, vector<int> T, vector<int> B, vector<int> L, vector<int> R){
memset(v, -1, sizeof v);
int n = (int)X.size();
if(n >= N){
for(int i = 1; i <= n; ++i)
par[i] = par[i-1]+X[i-1];
int Q = (int)T.size();
vector<ll> ans;
for(int i = 0; i < Q; ++i)
ans.pb(par[R[i]+1]-par[L[i]]);
return ans;
}
for(int i = 1; i <= n; ++i)
par[i] = par[i-1]+X[i-1], v[1][i] = X[i-1];
for(int i = 1; i <= n; ++i)
v[i][1] = Y[i-1];
auto wow = [&](int a, int b) -> int {
return (!(a|b)?1:0);
};
auto sm = [&](int x, int x1, int y, int y1) -> ll {
return (p[x1][y1]+p[x-1][y-1]-p[x-1][y1]-p[x1][y-1]);
};
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
if(v[i][j]==-1 and ~v[i-1][j] and ~v[i][j-1])
v[i][j] = wow(v[i-1][j], v[i][j-1]);
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
p[i][j] = p[i-1][j]+p[i][j-1]-p[i-1][j-1]+v[i][j];
int Q = (int)L.size();
vector<ll> ans;
for(int i = 0; i < Q; ++i)
ans.pb(sm(T[i]+1, B[i]+1, L[i]+1, R[i]+1));
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
99408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
99408 KB |
Output is correct |
2 |
Correct |
13 ms |
99436 KB |
Output is correct |
3 |
Correct |
12 ms |
99408 KB |
Output is correct |
4 |
Correct |
13 ms |
99292 KB |
Output is correct |
5 |
Correct |
14 ms |
99408 KB |
Output is correct |
6 |
Correct |
14 ms |
99308 KB |
Output is correct |
7 |
Correct |
13 ms |
99408 KB |
Output is correct |
8 |
Correct |
14 ms |
99408 KB |
Output is correct |
9 |
Correct |
12 ms |
99576 KB |
Output is correct |
10 |
Correct |
13 ms |
99388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
99408 KB |
Output is correct |
2 |
Correct |
13 ms |
99436 KB |
Output is correct |
3 |
Correct |
12 ms |
99408 KB |
Output is correct |
4 |
Correct |
13 ms |
99292 KB |
Output is correct |
5 |
Correct |
14 ms |
99408 KB |
Output is correct |
6 |
Correct |
14 ms |
99308 KB |
Output is correct |
7 |
Correct |
13 ms |
99408 KB |
Output is correct |
8 |
Correct |
14 ms |
99408 KB |
Output is correct |
9 |
Correct |
12 ms |
99576 KB |
Output is correct |
10 |
Correct |
13 ms |
99388 KB |
Output is correct |
11 |
Correct |
14 ms |
100432 KB |
Output is correct |
12 |
Correct |
14 ms |
100404 KB |
Output is correct |
13 |
Correct |
14 ms |
100432 KB |
Output is correct |
14 |
Correct |
14 ms |
100440 KB |
Output is correct |
15 |
Correct |
14 ms |
99808 KB |
Output is correct |
16 |
Correct |
13 ms |
99920 KB |
Output is correct |
17 |
Correct |
15 ms |
99920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
264 ms |
264008 KB |
Execution killed with signal 7 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
99408 KB |
Output is correct |
2 |
Correct |
13 ms |
99436 KB |
Output is correct |
3 |
Correct |
12 ms |
99408 KB |
Output is correct |
4 |
Correct |
13 ms |
99292 KB |
Output is correct |
5 |
Correct |
14 ms |
99408 KB |
Output is correct |
6 |
Correct |
14 ms |
99308 KB |
Output is correct |
7 |
Correct |
13 ms |
99408 KB |
Output is correct |
8 |
Correct |
14 ms |
99408 KB |
Output is correct |
9 |
Correct |
12 ms |
99576 KB |
Output is correct |
10 |
Correct |
13 ms |
99388 KB |
Output is correct |
11 |
Correct |
14 ms |
100432 KB |
Output is correct |
12 |
Correct |
14 ms |
100404 KB |
Output is correct |
13 |
Correct |
14 ms |
100432 KB |
Output is correct |
14 |
Correct |
14 ms |
100440 KB |
Output is correct |
15 |
Correct |
14 ms |
99808 KB |
Output is correct |
16 |
Correct |
13 ms |
99920 KB |
Output is correct |
17 |
Correct |
15 ms |
99920 KB |
Output is correct |
18 |
Correct |
182 ms |
303300 KB |
Output is correct |
19 |
Correct |
178 ms |
303044 KB |
Output is correct |
20 |
Correct |
175 ms |
303044 KB |
Output is correct |
21 |
Correct |
183 ms |
302892 KB |
Output is correct |
22 |
Correct |
171 ms |
303044 KB |
Output is correct |
23 |
Correct |
105 ms |
164292 KB |
Output is correct |
24 |
Correct |
101 ms |
164224 KB |
Output is correct |
25 |
Correct |
109 ms |
164224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
108912 KB |
Output is correct |
2 |
Runtime error |
265 ms |
262472 KB |
Execution killed with signal 7 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
275 ms |
262220 KB |
Execution killed with signal 7 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
264 ms |
264008 KB |
Execution killed with signal 7 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
99408 KB |
Output is correct |
2 |
Correct |
13 ms |
99408 KB |
Output is correct |
3 |
Correct |
13 ms |
99436 KB |
Output is correct |
4 |
Correct |
12 ms |
99408 KB |
Output is correct |
5 |
Correct |
13 ms |
99292 KB |
Output is correct |
6 |
Correct |
14 ms |
99408 KB |
Output is correct |
7 |
Correct |
14 ms |
99308 KB |
Output is correct |
8 |
Correct |
13 ms |
99408 KB |
Output is correct |
9 |
Correct |
14 ms |
99408 KB |
Output is correct |
10 |
Correct |
12 ms |
99576 KB |
Output is correct |
11 |
Correct |
13 ms |
99388 KB |
Output is correct |
12 |
Correct |
14 ms |
100432 KB |
Output is correct |
13 |
Correct |
14 ms |
100404 KB |
Output is correct |
14 |
Correct |
14 ms |
100432 KB |
Output is correct |
15 |
Correct |
14 ms |
100440 KB |
Output is correct |
16 |
Correct |
14 ms |
99808 KB |
Output is correct |
17 |
Correct |
13 ms |
99920 KB |
Output is correct |
18 |
Correct |
15 ms |
99920 KB |
Output is correct |
19 |
Runtime error |
264 ms |
264008 KB |
Execution killed with signal 7 |
20 |
Halted |
0 ms |
0 KB |
- |