cf div2 round 688 题解
爆零了,自闭了
小张做项目入职字节
小李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; int a[limit]; void solve(){ cin>>n>>m; set<int>s; rep(i,1,n){ int x; cin>>x; s.insert(x); } int tot = 0; rep(i,1,m){ int x; cin>>x; if(s.find(x) != s.end())++tot; } cout<<tot<<endl; } int main() { #ifdef LOCAL FOPEN; #endif cin>>kase; while (kase--){ solve(); } return 0; }
B题,我现在其实没太搞懂这个怎么搞的,挖坑
#include <bits/stdc++.h> using namespace std; #define limit (3150000 + 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]; ll dp2[limit],dp[limit]; void solve(){ cin>>n; ll tot = 0,ans = 0x3f3f3f3f3f3f3f; rep(i,1,n){ cin>>a[i]; dp[i] = 0; dp2[i] = 0; } dp2[1] = max(dp2[1],llabs(a[2] - a[1])); rep(i,2,n){ ll tmp = llabs(a[i] - a[i - 1]); tot += tmp; dp[i] = tmp; } rep(i,1,n){ if(i == 1){ ans = min(ans , tot - dp[2]); }else if(i == n){ ans = min(ans,tot - dp[n]); } else if((a[i] <= a[i + 1] && a[i] <= a[i - 1])){ ans = min(ans,tot + abs(a[i - 1] - a[i + 1]) - dp[i + 1 ] - dp[i]); }else if(a[i] >= a[i + 1] && a[i] >= a[i - 1]){ ans = min(ans,tot + abs(a[i + 1] - a[i - 1]) - dp[i + 1] - dp[i]); } } cout<<ans<<endl; } int main() { #ifdef LOCAL FOPEN; #endif cin>>kase; while (kase--){ solve(); } return 0; }
C这个思路很显然,就是看每次(1)是否能选取到两个端点,然后贪心去放第三个顶点,因为我们可以改变一个格子,所以肯定要顶着1或者n放
(2)我们只用一个端点到两边,看哪个底大,是否能构成更大的三角形,顶点是否存在
(3)同上,但这次只有一个顶点
(4)这一行没顶点,拉闸
极不好写,100+的大暴力,给人写自闭了,不过好在1A,写完一身汗
#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, 其他结论今晚再搞
奥里给!
天才选手zerol的主页:https://zerol.me/
|
WeepingDemon的个人主页:https://weepingdemon.gitee.io/blog/