#include<bits/stdc++.h> #define tpname typename #define Go(i , x , y) for(register int i = x; i <= y; i++) #define God(i , y , x) for(register int i = y; i >= x; i--) typedeflonglong LL; typedeflongdouble ld; typedefunsignedlonglong ULL; template < tpname T > voidsc(T& t){ char c = getchar(); T x = 1; t = 0; while(!isdigit(c)) {if(c == '-') x = -1; c = getchar();} while(isdigit(c)) t = t * 10 + c - '0' , c = getchar();t *= x; } template < tpname T , tpname... Args > voidsc(T& t , Args&... args){sc(t); sc(args...);} template < tpname T > T mul(T x , T y , T _){ x %= _,y %= _; return ((x * y - (T)(((ld)x * y + 0.5) / _) * _) % _ + _) % _; }
constint N = 100000 + 10; int pref[3][N] , suf[3][N];
int n , ans = 0 , t[N]; intmain(){ sc(n); Go(i,1,n) sc(t[i]); std::vector < int > v; int cnt = 1; Go(i , 2 , n+1) { if(t[i] != t[i - 1]) { v.push_back(cnt); cnt = 0; } cnt++; }
#include<bits/stdc++.h> #define tpname typename #define Go(i , x , y) for(register int i = x; i <= y; i++) #define God(i , y , x) for(register int i = y; i >= x; i--) typedeflonglong LL; typedeflongdouble ld; typedefunsignedlonglong ULL; template < tpname T > voidsc(T& t){ char c = getchar(); T x = 1; t = 0; while(!isdigit(c)) {if(c == '-') x = -1; c = getchar();} while(isdigit(c)) t = t * 10 + c - '0' , c = getchar();t *= x; } template < tpname T , tpname... Args > voidsc(T& t , Args&... args){sc(t); sc(args...);} template < tpname T > T mul(T x , T y , T _){ x %= _,y %= _; return ((x * y - (T)(((ld)x * y + 0.5) / _) * _) % _ + _) % _; }
#include<bits/stdc++.h> #define tpname typename #define Go(i , x , y) for(register int i = x; i <= y; i++) #define God(i , y , x) for(register int i = y; i >= x; i--) typedeflonglong LL; typedeflongdouble ld; typedefunsignedlonglong ULL; template < tpname T > voidsc(T& t){ char c = getchar(); T x = 1; t = 0; while(!isdigit(c)) {if(c == '-') x = -1; c = getchar();} while(isdigit(c)) t = t * 10 + c - '0' , c = getchar();t *= x; } template < tpname T , tpname... Args > voidsc(T& t , Args&... args){sc(t); sc(args...);} template < tpname T > T mul(T x , T y , T _){ x %= _,y %= _; return ((x * y - (T)(((ld)x * y + 0.5) / _) * _) % _ + _) % _; }
constint N = 1000 + 10; int ans[N][N]; int n , m , it; int a[N][N] , b[N];
int ans1[N][N] , ans2[N][N] , big1[N][N] , big2[N][N]; int p = 0; intmain(){ sc(n , m); Go(i , 1 , n) Go(j , 1 , m) sc(a[i][j]);
Go(i , 1 , n) { p = 0; Go(j , 1 , m) b[++p] = a[i][j]; std::sort(b + 1 , b + p + 1); p = std::unique(b + 1 , b + p + 1) - (b + 1); Go(j , 1 , m) { ans1[i][j] = std::lower_bound(b+1 , b+p+1 , a[i][j]) - b; big1[i][j] = p - ans1[i][j]; } } Go(i , 1 , m) { p = 0; Go(j , 1 , n) b[++p] = a[j][i]; std::sort(b + 1 , b + p + 1); p = std::unique(b + 1 , b + p + 1) - (b + 1); Go(j , 1 , n) { ans2[j][i] = std::lower_bound(b+1 , b+p+1 , a[j][i]) - b; big2[j][i] = p - ans2[j][i]; } } Go(i , 1 , n) { Go(j , 1 , m) printf("%d " , std::max(ans1[i][j] , ans2[i][j]) + std::max(big1[i][j] , big2[i][j])); puts(""); } return0; }
#include<bits/stdc++.h> #define tpname typename #define Go(i , x , y) for(register int i = x; i <= y; i++) #define God(i , y , x) for(register int i = y; i >= x; i--) typedeflonglong LL; typedeflongdouble ld; typedefunsignedlonglong ULL; template < tpname T > voidsc(T& t){ char c = getchar(); T x = 1; t = 0; while(!isdigit(c)) {if(c == '-') x = -1; c = getchar();} while(isdigit(c)) t = t * 10 + c - '0' , c = getchar();t *= x; } template < tpname T , tpname... Args > voidsc(T& t , Args&... args){sc(t); sc(args...);} template < tpname T > T mul(T x , T y , T _){ x %= _,y %= _; return ((x * y - (T)(((ld)x * y + 0.5) / _) * _) % _ + _) % _; }