# Explanation of CF div2 round 688

2020-12-05 16:59:45 tiany7

It's gone , It's closed

Xiao Zhang does project entry byte

petty thief ak wf induction ms

I compete for zero salary 3k

We all have a bright future

ok , This feeling is a little bit difficult , I almost got stuck in yesterday B On , Not to accept O I will help you boom zero 了

The first question is , It looks like a bluff , I think we have to record variables and so on ,1 Minutes later, we found that we only need to find out the intersection size of the two sets , You don't even need to increment variables , Take a blood , here rk 1k6, I'm gone

```#include <bits/stdc++.h>
using namespace std;
#define limit (315000 + 5)// Prevent overflow
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3f
#define lowbit(i) i&(-i)// One step, two steps
#define EPS 1e-6
#define FASTIO  ios::sync_with_stdio(false);cin.tie(0);
#define ff(a) printf("%d\n",a );
#define pi(a,b) pair<a,b>
#define rep(i, a, b) for(ll i = a; i <= b ; ++i)
#define per(i, a, b) for(ll i = b ; i >= a  ; --i)
#define MOD 998244353
#define traverse(u) for(int i = head[u]; ~i ; i = edge[i].next)
#define FOPEN freopen("C:\\Users\\tiany\\CLionProjects\\acm_01\\data.txt", "rt", stdin)
#define FOUT freopen("C:\\Users\\tiany\\CLionProjects\\acm_01\\dabiao.txt", "wt", stdout)
#define debug(x) cout<<x<<endl
typedef long long ll;
typedef unsigned long long ull;
ll sign = 1, x = 0;char s = getchar();
while(s > '9' || s < '0' ){if(s == '-')sign = -1;s = getchar();}
while(s >= '0' && s <= '9'){x = (x << 3) + (x << 1) + s - '0';s = getchar();}
return x * sign;
void write(ll x){
if(x < 0) putchar('-'),x = -x;
if(x / 10) write(x / 10);
putchar(x % 10 + '0');
}
int kase;
int n,m,k;
ll a[limit];
int mp[2005][2006];
int l[2005][11],r[2005][11],up[2005][11],down[2006][11];
void solve(){
cin>>n;
rep(i,0,9)a[i] = 0;
rep(i,1,n){
string str;
cin>>str;
rep(h,0,9)l[i][h] = r[i][h] =down[i][h] =up[i][h] =0;
rep(j,1,n){
mp[i][j] = str[j-1] - '0';
}
}
rep(i,1,n){
rep(p,0,9){
rep(j,1,n){
if(mp[i][j] == p){
r[i][p] = j;
break;
}
}
per(j,1,n){
if(mp[i][j] == p){
l[i][p] = j;
break;
}
}
}
}
rep(j,1,n){
rep(p,0,9){
rep(i,1,n){
if(mp[i][j] == p){
down[j][p] = i;
break;
}
}
per(i,1,n){
if(mp[i][j] == p){
up[j][p] = i;
break;
}
}
}
}
rep(p,0,9){
rep(i,1,n){
if(l[i][p] != r[i][p]){
int base = abs(l[i][p] - r[i][p]);
a[p] = max({a[p],base * abs(1 - i), base * abs(n - i)});
base = max(abs(l[i][p] - 1), abs(l[i][p] - n));
rep(j,1,n){
if(up[j][p])a[p] = max({a[p], base * abs(up[j][p] - i), base* abs(down[j][p] - i)});
}
base = max(abs(r[i][p] - 1), abs(r[i][p] - n));
rep(j,1,n){
if(up[j][p])a[p] = max({a[p], base * abs(up[j][p] - i), base* abs(down[j][p] - i)});
}
}else if(l[i][p]){
int base = max(abs(1 - l[i][p]),abs(l[i][p] - n));
rep(j,1,n){
if(up[j][p])a[p] = max({a[p], base * abs(up[j][p]- i),base * abs(down[j][p] - i)});
}
}
if(up[i][p] != down[i][p]){
int base = abs(up[i][p] - down[i][p]);
a[p] = max({a[p],base * abs(1 - i), base * abs(n - i)});
base = max(abs(up[i][p] - 1), abs(up[i][p] - n));
rep(j,1,n){
if(l[j][p])a[p] = max({a[p],base * abs(l[j][p] - i), base * abs(r[j][p] - i)});
}
base = max(abs(down[i][p] - 1), abs(down[i][p] - n));
rep(j,1,n){
if(l[j][p])a[p] = max({a[p],base * abs(l[j][p] - i), base * abs(r[j][p] - i)});
}
}else if(up[i][p]){
int base = max(abs(1 - up[i][p]),abs(down[i][p] - n));
rep(j,1,n){
if(l[j][p])a[p] = max({a[p], base * abs(l[j][p]- i),base * abs(r[j][p] - i)});
}
}
}
}
rep(i,0,9){
cout<<a[i]<<' ';
}
cout<<endl;
}
int main() {
#ifdef LOCAL
FOPEN;
#endif
cin>>kase;
while (kase--){
solve();
}
return 0;
}```

D There's no time for the problem , But then he and Dxtst Elder brother discussed, it seems to be in the current position 0 or 1, If it is 1 The contribution to the answer is 2^k, Other conclusions will be made tonight

Origie ！

https://chowdera.com/2020/12/20201205165819860i.html