# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1043295 |
2024-08-04T07:53:39 Z |
idas |
Rectangles (IOI19_rect) |
C++17 |
|
115 ms |
40484 KB |
#include "rect.h"
#include "bits/stdc++.h"
#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
using namespace std;
const int MxN=2510;
int n, m, a[MxN][MxN];
bool st_node(int i, int j, int in) {
if(in==0) return a[i][j]==0 && a[i][j-1]==1 && a[i-1][j]==1 && a[i+1][j]==1;
return a[i][j]==0 && a[i-1][j]==1 && a[i][j-1]==1 && a[i][j+1]==1;
}
bool nd_node(int i, int j, int in) {
if(in==0) return a[i][j]==0 && a[i-1][j]==1 && a[i+1][j]==1 && a[i][j+1]==1;
return a[i][j]==0 && a[i+1][j]==1 && a[i][j-1]==1 && a[i][j+1]==1;
}
bool mid_node(int i, int j, int in) {
if(in==0) return a[i][j]==0 && a[i-1][j]==1 && a[i+1][j]==1;
return a[i][j]==0 && a[i][j-1]==1 && a[i][j+1]==1;
}
bool sqr(int i, int j) {
return a[i][j]==0 && a[i+1][j]==1 && a[i-1][j]==1 && a[i][j-1]==1 && a[i][j+1]==1;
}
long long count_rectangles(std::vector<std::vector<int> > A) {
n=A.size(); m=A[0].size();
FOR(i, 0, n) FOR(j, 0, m) a[i][j]=A[i][j];
int ans=0;
FOR(i, 1, n-1) FOR(j, 1, m-1) if(sqr(i, j)) ans++;
FOR(i, 1, n-1) {
bool started=false;
FOR(j, 1, m-1) {
if(st_node(i, j, 0)) {
started=true;
}
else if(nd_node(i, j, 0)) {
if(started) ans++;
}
else if(!mid_node(i, j, 0)) {
started=false;
}
}
}
FOR(j, 1, m-1) {
bool started=false;
FOR(i, 1, n-1) {
if(st_node(i, j, 1)) {
started=true;
}
else if(nd_node(i, j, 1)) {
if(started) ans++;
}
else if(!mid_node(i, j, 1)) {
started=false;
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
115 ms |
40484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |