占个坑先,希望不要掉的太惨了吧,不要掉到上一次之前的rating

upt:flag竟然没到,开心。

A - New Year and the Christmas Ornament

好像没什么可说的。

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<cctype>
using namespace std; typedef long long ll;
const int Maxn=210000; int main() {
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a+1<=b&&a+2<=c) {
printf("%d",3*a+3);
}
else if(b<=a+1&&b+1<=c) {
printf("%d",3*b);
}
else if(c<=a+2&&c<=b+1) {
printf("%d",3*c-3);
}
return 0;
}

B - New Year and the Treasure Geolocation

有一个显然的结论,x的最小值加的一定是最大的x变化量,y同理。因为数据保证有解那么直接找即可。

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<cctype>
using namespace std; typedef long long ll;
const int Maxn=210000; int n,x[Maxn],y[Maxn],a[Maxn],b[Maxn]; int main() {
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d",&x[i],&y[i]);
sort(x+1,x+n+1),sort(y+1,y+n+1);
for(int i=1;i<=n;i++)
scanf("%d%d",&a[i],&b[i]);
sort(a+1,a+n+1),sort(b+1,b+n+1);
printf("%d %d\n",x[1]+a[n],y[1]+b[n]);
return 0;
}

C - New Year and the Sphere Transmission

考虑两个数产生的答案不同当且仅当他们与n的gcd不同,那么就枚举n的约数,然后计算即可,具体参考代码。

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<cctype>
using namespace std; typedef long long ll;
const int Maxn=210000; int n,num;
ll x[Maxn]; void work(int n,int k) {
ll d=n/k;
x[++num]=n*(d-1)/2+d;
} int main() {
scanf("%d",&n);
for(int i=1;i*i<=n;i++)
if(n%i==0) {
work(n,i);
work(n,n/i);
}
sort(x+1,x+num+1);
for(int i=1;i<=num;i++) if(x[i]!=x[i-1]) printf("%I64d ",x[i]);
return 0;
}

D - New Year and the Permutation Concatenation

瞎猜了一波规律就过了,具体也说不清楚。。

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<cctype>
using namespace std; typedef long long ll;
const int Maxn=2100000;
const int mod=998244353; int n;
ll jc[Maxn],ans; ll powp(ll a,ll b) {
ll ans=1;
while(b) {
if(b&1) ans=ans*a%mod;
a=a*a%mod;
b>>=1;
}
return ans;
} ll C(int x,int y) {
return jc[x]*powp(jc[y],mod-2)%mod*powp(jc[x-y],mod-2)%mod;
} int main() {
scanf("%d",&n);
jc[0]=1;
for(int i=1;i<=n;i++)
jc[i]=jc[i-1]*i%mod;
for(int i=0;i<=n;i++) ans=(ans+C(n,i)*(jc[i]-1)%mod*jc[n-i]%mod)%mod;
ans=(ans+1)%mod;
printf("%I64d\n",ans);
return 0;
}

E - New Year and the Acquaintance Estimation

这个就是根据题目里面的链接,根据里面的一个结论,设第\(i\)个点的度数为\(d_i\),将所有的点的度数排起来,即\(d_1\ge d_2 \ge \cdots \ge d_n\),那么这个图合法当且仅当对于所有的\(1\le k \le n\),满足\(\sum_{i=1}^kd_i\le k\cdot (k-1)+\sum_{i=k+1}^nmin(d_i,k)\),具体证明请参考题目里面的维基百科连接。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; typedef long long ll;
const int Maxn=2100000; int n,d[Maxn],bj[Maxn],ans[Maxn],num;
ll pre[Maxn]; int main() {
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&d[i]);
sort(d,d+n);
for(int i=1;i<=n;i++) pre[i]=pre[i-1]+d[i-1];
int j=0;
for(int k=1;k<=n;k++) {
ll l=pre[n]-pre[n-k],r=(ll)k*(k-1);
while(j<n&&d[j]<k) j++;
r+=pre[min(j,n-k)]+1ll*max(0,n-k-j)*k;
ll now=d[n-k],diff=l-r;
if(diff<=k&&diff<=now) {
bj[max(diff,0ll)]++;
bj[now+1]--;
}
l-=d[n-k],r+=min(d[n-k],k);
diff=r-l;
if(diff>=now+1) {
bj[now+1]++;
bj[min(diff+1,(ll)n+1)]--;
}
}
j=0;
for(int i=0;i<=n;i++) {
j+=bj[i];
if(j==n&&(pre[n]+i&1)==0) ans[++num]=i;
}
if(num==0) puts("-1");
else for(int i=1;i<=num;i++) printf("%d ",ans[i]);
return 0;
}

F - New Year and the Mallard Expedition

这个就是贪心,首先每次走的距离都是半米的倍数,而且在岩浆上一定要用体力,如果体力不够的话就必须往回走,那么在水上走一定要比在地上走要优。

然后剩余的体力一定要在地上用,如果地上剩下了再在水上用,这样二分一下在地上能用多少,然后计算答案。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; typedef long long ll;
const int Maxn=110000; int n;
ll l[Maxn],a[Maxn],ans;
char s[Maxn]; int main() {
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%I64d",&l[i]);
scanf("%s",s+1);
for(int i=1;i<=n;i++) l[i]<<=1;
ll w=0,g=0,st=1,flag=5;
for(int i=1;i<=n;i++) {
if(s[i]=='G') g+=l[i],ans+=5*l[i];
if(s[i]=='W') w+=l[i],flag=3,ans+=3*l[i];
if(s[i]=='L') {
ans+=l[i];
ll re=l[i],sxz=min(re,w);
re-=sxz,w-=sxz;sxz=min(re,g);
re-=sxz,g-=sxz;
if(re) ans+=re*flag;
}
if(!g&&!w) st=i+1;
}
ll las=(g+w)/2;
if(las) {
ll lc=0,rc=0,mid,res=0;
for(int i=st;i<=n;i++) if(s[i]=='G') rc+=l[i];
rc=min(rc,las);
while(lc<=rc) {
mid=lc+rc>>1;ll re=mid;
for(int i=n;i>=st;i--)
if(s[i]=='G') {
a[i]=min(re,l[i]);
re-=a[i];
}
ll now=0;
for(int i=st;i<=n;i++) {
if(s[i]=='G') now+=l[i]-2*a[i];
if(s[i]=='W') now+=l[i];
if(s[i]=='L') now-=l[i];
if(now<0) {
rc=mid-1;
goto orznh;
}
}
lc=mid+1;res=mid;
orznh:;
}
ans-=res*4+(las-res)*2;
}
ans>>=1;printf("%I64d\n",ans);
return 0;
}

Codeforces 1091 Good Bye 2018的更多相关文章

  1. Codeforces:Good Bye 2018(题解)

    Good Bye 2018! 题目链接:https://codeforces.com/contest/1091 A. New Year and the Christmas Ornament 题意: 给 ...

  2. Codeforces Good Bye 2018

    咕bye 2018,因为我这场又咕咕咕了 无谓地感慨一句:时间过得真快啊(有毒 A.New Year and the Christmas Ornament 分类讨论后等差数列求和 又在凑字数了 #in ...

  3. Good Bye 2018 (A~F, H)

    目录 Codeforces 1091 A.New Year and the Christmas Ornament B.New Year and the Treasure Geolocation C.N ...

  4. Codeforces Avito Code Challenge 2018 D. Bookshelves

    Codeforces Avito Code Challenge 2018 D. Bookshelves 题目连接: http://codeforces.com/contest/981/problem/ ...

  5. Good Bye 2018

    Good Bye 2018 2018年最后一场CF,OVER! 弱弱的我只能做出3道A,B,D~~~~ 最后几分钟,感觉找到了C题的规律,结束的那一刻,提交了一发 "Wrong answer ...

  6. Good Bye 2018题解

    Good Bye 2018题解 题解 CF1091A [New Year and the Christmas Ornament] 打完cf都忘记写题解了qwq 题意就是:给你一些黄,蓝,红的球,满足蓝 ...

  7. Codeforces Good Bye 2018 D (1091D) New Year and the Permutation Concatenation

    题意:给n!个n的排列,按字典序从小到大连成一条序列,例如3的情况为:[1,2,3, 1,3,2, 2,1,3 ,2,3,1 ,3,1,2 ,3,2,1],问其中长度为n,且和为sum=n*(n+1) ...

  8. [codeforces Mail.Ru Cup 2018 Round 3][B Divide Candies ][思维+数学]

    https://codeforces.com/contest/1056/problem/B 题意:输入n,m    求((a*a)+(b*b))%m==0的(a,b)种数(1<=a,b<= ...

  9. [codeforces Mail.Ru Cup 2018 Round 1 D][ xor 操作]

    http://codeforces.com/contest/1054/problem/D 题目大意:一个序列a1 a2...an,可以对若干个元素进行取反,使所得的新序列异或和为0的区间个数最多. 题 ...

随机推荐

  1. Kafka性能

    基准测试Apache Kafka:每秒写入2百万(在三台便宜的机器上) 核心的数据枢纽一定是高效的,可预测的,并且容易扩展.Kafka能够做到在普通的硬件上支撑每秒百万次写入. Kafka的数据模型非 ...

  2. 查看win信任的证书办法机构(CA机构的公钥)

    cmd mmc

  3. JVM学习笔记-内存管理

    第一章 内存分配 1. 内存区域.     方法区和堆(线程共享),程序计数器 , VM栈 和 本地方法栈(线程隔离).     1) java虚拟机栈:线程私有.描写叙述的是java方法执行的内存模 ...

  4. #if的使用说明

    #if的后面接的是表达式 #if (MAX==10)||(MAX==20) code... #endif 它的作用是:如果(MAX==10)||(MAX==20)成立,那么编译器就会把其中的#if 与 ...

  5. 万恶之源 - Python基础数据类型一

    整数 整数在Python中的关键字用int来表示; 整型在计算机中运于计算和比较 在32位机器上int的范围是:  -2**31-2**31-1,即-2147483648-2147483647 在64 ...

  6. POJ2983 Is the Information Reliable?

    http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=267#problem/B                        B -  ...

  7. Message Flood(map)

    http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=203#problem/D 以前用字典树做过 #include <strin ...

  8. ML实践详细经典教程----用例图、顺序图、状态图、类图、包图、协作图

    面向对象的问题的处理的关键是建模问题.建模可以把在复杂世界的许多重要的细节给抽象出.许多建模工具封装了UML(也就是Unified Modeling Language?),这篇课程的目的是展示出UML ...

  9. [LeetCode] 72. Edit Distance_hard tag: Dynamic Programming

    Given two words word1 and word2, find the minimum number of operations required to convert word1to w ...

  10. Qt事件过滤器和事件的发送

    事件过滤器 /* *事件过滤器不是类,仅仅是QObject类的两个函数:installEventFilter() 和 eventFilter() . *下面讲个例子: * 监视过滤 textEdit的 ...