# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1019232 |
2024-07-10T16:00:15 Z |
mindiyak |
Rectangles (IOI19_rect) |
C++17 |
|
5000 ms |
520816 KB |
#include "rect.h"
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<long> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;
int N,M;
vvi arr;
ll ans = 0;
set<pair<pi,pi>> visited;
void dfs(int a,int b,int c,int d,int wa,int wb,int wc,int wd){
if(c<a)swap(a,c);
if(d<b)swap(b,d);
if(visited.count({{a,b},{c,d}}))return;
if(a == 0 || b == 0 || c == (N-1) || d == (M-1))return;
visited.insert({{a,b},{c,d}});
bool bad = false;
FOR(i,min(a,wa),max(wc,c)+1){
FOR(j,min(b,wb),max(wd,d)+1){
// if(arr[i][j] >= arr[b-1][j])return;
// if(arr[i][j] >= arr[d+1][j])return;
// if(arr[i][j] >= arr[i][a-1])return;
// if(arr[i][j] >= arr[i][c+1])return;
if(arr[i][j] >= arr[i][b-1])bad = true;
if(arr[i][j] >= arr[i][d+1])bad = true;
if(arr[i][j] >= arr[a-1][j])bad = true;
if(arr[i][j] >= arr[c+1][j])bad = true;
if(bad)break;
}
}
// cout << a << " " << b << " " << c << " " << d << " " << bad << endl;
if(!bad)ans ++;
if(!bad){wa=a;wb=b;wc=c;wd=d;}
dfs(a-1,b,c,d,wa,wb,wc,wd);
dfs(a,b-1,c,d,wa,wb,wc,wd);
dfs(a,b,c+1,d,wa,wb,wc,wd);
dfs(a,b,c,d+1,wa,wb,wc,wd);
}
ll count_rectangles(vvi a) {
N = a.size();M = a[0].size();
arr = a;
FOR(i,1,N-1){
FOR(j,1,M-1){
dfs(i,j,i,j,i,j,i,j);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
77 ms |
10712 KB |
Output is correct |
3 |
Correct |
78 ms |
10624 KB |
Output is correct |
4 |
Correct |
77 ms |
10544 KB |
Output is correct |
5 |
Correct |
77 ms |
10580 KB |
Output is correct |
6 |
Correct |
77 ms |
10580 KB |
Output is correct |
7 |
Correct |
16 ms |
2008 KB |
Output is correct |
8 |
Correct |
10 ms |
1628 KB |
Output is correct |
9 |
Correct |
80 ms |
10612 KB |
Output is correct |
10 |
Correct |
83 ms |
10580 KB |
Output is correct |
11 |
Correct |
93 ms |
10580 KB |
Output is correct |
12 |
Correct |
79 ms |
10576 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
436 KB |
Output is correct |
19 |
Correct |
91 ms |
10552 KB |
Output is correct |
20 |
Correct |
17 ms |
2652 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
77 ms |
10712 KB |
Output is correct |
3 |
Correct |
78 ms |
10624 KB |
Output is correct |
4 |
Correct |
77 ms |
10544 KB |
Output is correct |
5 |
Correct |
77 ms |
10580 KB |
Output is correct |
6 |
Correct |
77 ms |
10580 KB |
Output is correct |
7 |
Correct |
16 ms |
2008 KB |
Output is correct |
8 |
Correct |
10 ms |
1628 KB |
Output is correct |
9 |
Correct |
80 ms |
10612 KB |
Output is correct |
10 |
Correct |
83 ms |
10580 KB |
Output is correct |
11 |
Correct |
93 ms |
10580 KB |
Output is correct |
12 |
Correct |
79 ms |
10576 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
436 KB |
Output is correct |
19 |
Correct |
91 ms |
10552 KB |
Output is correct |
20 |
Correct |
17 ms |
2652 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Execution timed out |
5039 ms |
520816 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
77 ms |
10712 KB |
Output is correct |
3 |
Correct |
78 ms |
10624 KB |
Output is correct |
4 |
Correct |
77 ms |
10544 KB |
Output is correct |
5 |
Correct |
77 ms |
10580 KB |
Output is correct |
6 |
Correct |
77 ms |
10580 KB |
Output is correct |
7 |
Correct |
16 ms |
2008 KB |
Output is correct |
8 |
Correct |
10 ms |
1628 KB |
Output is correct |
9 |
Correct |
80 ms |
10612 KB |
Output is correct |
10 |
Correct |
83 ms |
10580 KB |
Output is correct |
11 |
Correct |
93 ms |
10580 KB |
Output is correct |
12 |
Correct |
79 ms |
10576 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Execution timed out |
5039 ms |
520816 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
77 ms |
10712 KB |
Output is correct |
3 |
Correct |
78 ms |
10624 KB |
Output is correct |
4 |
Correct |
77 ms |
10544 KB |
Output is correct |
5 |
Correct |
77 ms |
10580 KB |
Output is correct |
6 |
Correct |
77 ms |
10580 KB |
Output is correct |
7 |
Correct |
16 ms |
2008 KB |
Output is correct |
8 |
Correct |
10 ms |
1628 KB |
Output is correct |
9 |
Correct |
80 ms |
10612 KB |
Output is correct |
10 |
Correct |
83 ms |
10580 KB |
Output is correct |
11 |
Correct |
93 ms |
10580 KB |
Output is correct |
12 |
Correct |
79 ms |
10576 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Execution timed out |
5039 ms |
520816 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2482 ms |
195884 KB |
Output is correct |
2 |
Correct |
1623 ms |
141392 KB |
Output is correct |
3 |
Correct |
2409 ms |
195748 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
2258 ms |
195920 KB |
Output is correct |
6 |
Correct |
2312 ms |
195784 KB |
Output is correct |
7 |
Correct |
2319 ms |
195876 KB |
Output is correct |
8 |
Correct |
2338 ms |
195904 KB |
Output is correct |
9 |
Correct |
2343 ms |
195988 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
436 KB |
Output is correct |
3 |
Correct |
91 ms |
10552 KB |
Output is correct |
4 |
Correct |
17 ms |
2652 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
5072 ms |
126344 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
77 ms |
10712 KB |
Output is correct |
3 |
Correct |
78 ms |
10624 KB |
Output is correct |
4 |
Correct |
77 ms |
10544 KB |
Output is correct |
5 |
Correct |
77 ms |
10580 KB |
Output is correct |
6 |
Correct |
77 ms |
10580 KB |
Output is correct |
7 |
Correct |
16 ms |
2008 KB |
Output is correct |
8 |
Correct |
10 ms |
1628 KB |
Output is correct |
9 |
Correct |
80 ms |
10612 KB |
Output is correct |
10 |
Correct |
83 ms |
10580 KB |
Output is correct |
11 |
Correct |
93 ms |
10580 KB |
Output is correct |
12 |
Correct |
79 ms |
10576 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Execution timed out |
5039 ms |
520816 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |