# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472632 | robell | Bob (COCI14_bob) | C++17 | 1095 ms | 14920 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long ll;
#define pb push_back
#define eb emplace_back
#define countbits __builtin_popcount
#define beg0 __builtin_clz
#define terminal0 __builtin_ctz
#define mod 1e9+7
void setIO(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
}
void setIO(string f){
freopen((f+".in").c_str(),"r",stdin);
freopen((f+".out").c_str(),"w",stdout);
setIO();
}
int N, M;
int g[1000][1000];
bool v[1000][1000];
int num = 0;
int minx = 1000;
int maxx = -1;
int miny = 1000;
int maxy = -1;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
void dfs(int x, int y, int n){
if (x<0 || x>=N || y<0 || y>=M) return;
if (v[x][y]||g[x][y]!=n) return;
v[x][y]=true; num++;
minx=min(x,minx);
maxx=max(x,maxx);
miny=min(y,miny);
maxy=max(y,maxy);
for (int i=0;i<4;i++) dfs(x+dx[i],y+dy[i],n);
}
int main(){
setIO();
cin >> N >> M;
for (int i=0;i<N;i++){
for (int j=0;j<M;j++){
cin >> g[i][j];
v[i][j]=false;
}
}
ll rects = 0;
for (int i=0;i<N;i++){
for (int j=i;j<N;j++){
int prev = 0; int pval = -1;
for (int k=0;k<M;k++){
if (pval<0){
bool w = false;
for (int z=i;z<=j;z++){
if (g[i][k]!=g[z][k]){
w=true;
break;
}
}
if (!w){
rects+=(++prev);
pval=g[i][k];
}
}else{
bool w = false;
for (int z=i;z<=j;z++){
if (g[z][k]!=pval){
w=true;
break;
}
}
if (!w){
rects+=(++prev);
}else{
k--;
pval=-1;
prev=0;
}
}
}
}
}
cout << rects << "\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |