当前位置:网站首页>cf div2 round 688 题解

cf div2 round 688 题解

2020-12-05 16:59:45 tiany7

爆零了,自闭了

小张做项目入职字节

小李ak wf入职ms

我比赛爆零月薪3k

我们都有光明的前途

好吧,这场感觉有一点难了,昨天差点卡死在B上,要不受O爷出手相救我就boom zero了

第一题,看上去很唬人,我觉得还得记录变量什么的,1分钟后发现只要查出两个集合的交集大小就行了,连变量增量都不用,拿一血,此时rk 1k6,我人没了

#include <bits/stdc++.h>
using namespace std;
#define limit (315000 + 5)//防止溢出
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3f
#define lowbit(i) i&(-i)//一步两步
#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;
inline ll read(){
    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题没时间搞了,但后来和Dxtst老哥讨论了下似乎是当前位上0或1,如果是1对于答案的贡献为2^k, 其他结论今晚再搞

奥里给!

版权声明
本文为[tiany7]所创,转载请带上原文链接,感谢
https://www.cnblogs.com/tiany7/p/14090229.html