# Codeforces round #467 (div. 2) 解题报告

## 水题round

Posted by yjjr's blog on March 9, 2018

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
{
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,a[106],ans=0;
int main()
{
sort(a+1,a+1+n);
rep(i,1,n)if(a[i]!=a[i-1])ans++;
cout<<ans<<endl;
return 0;
}


# B. Vile Grasshoppers

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
#define lson (x<<1)
#define rson (x<<1|1)
using namespace std;
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int x,y;
int main()
{
dep(i,y,x+1){
bool flag=1;
for(int j=2;j<=min((int)trunc(sqrt(i))+1,x);j++)
if(i%j==0){flag=0;break;}
if(flag){cout<<i;return 0;}
}
printf("-1");
return 0;
}


# C. Save Energy!

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
#define lson (x<<1)
#define rson (x<<1|1)
using namespace std;
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}

ll t,k,d,ans;
int main()
{
cin>>k>>d>>t;
ll x=k/d*d+(k%d!=0)*d;t*=2ll;
ll y=t/(2ll*k+(x-k));ans+=y*x;t-=y*(2ll*k+(x-k));
if(t>=2ll*k){ans+=k+(t-2ll*k);printf("%lld.0\n",ans);}
else{
ans+=t/2;
if(t%2)printf("%lld.5\n",ans);else printf("%lld.0\n",ans);
}
return 0;
}


# D. Sleepy Game

vis[i][0/1]表示到第i个点经过边数为奇/偶数

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
#define lson (x<<1)
#define rson (x<<1|1)
#define mid ((l+r)>>1)
#define pi acos(-1)
#define mp make_pair
#define pb push_back
#define pa pair<int,int>
#define fi first
#define se second
#define lowbit(x) ((x)&(-x))
#define mod (ll)1e9+7
using namespace std;
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
inline ll getgcd(ll x,ll y){return !x?y:getgcd(y%x,x);}
inline ll getlcm(ll x,ll y){return x/getgcd(x,y)*y;}
inline ll qpow(int x,int y){
ll re=1;
while(y){
if(y&1)re=(re*x)%mod;
y>>=1,x=(x*x)%mod;
}
return re;
}
const int maxn=1e5+6;
vector<int>a[maxn],b;
int vis[maxn][2],pre[maxn][2],vs[maxn],n,m,s;
void dfs(int fr,int x,int d){
if(vis[x][d]==1)return;
vis[x][d]=1;pre[x][d]=fr;
for(int i=0;i<a[x].size();i++)dfs(x,a[x][i],d^1);
}
inline bool loop(int x){
vs[x]=1;
bool flag=0;
for(int i=0;i<a[x].size();i++){
if(vs[a[x][i]]==1)flag=1;else if(vs[a[x][i]]==0)flag=loop(a[x][i]);
if(flag)return 1;
}
vs[x]=2;
return 0;
}
int main()
{
rep(i,1,n){
}
dfs(0,s,0);
rep(i,1,n)
if(vis[i][1]&&a[i].size()==0){
int tmp=i,t=1;
b.pb(tmp);
while(pre[tmp][t]!=0){
b.pb(pre[tmp][t]);
tmp=pre[tmp][t];
t^=1;
}
puts("Win");
dep(j,b.size()-1,0)printf("%d ",b[j]);
return 0;
}
if(loop(s))puts("Draw");else puts("Lose");
return 0;
}


# E. Lock Puzzle

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
#define lson (x<<1)
#define rson (x<<1|1)
#define mid ((l+r)>>1)
#define pi acos(-1)
#define mp make_pair
#define pb push_back
#define pa pair<int,int>
#define fi first
#define se second
#define lowbit(x) ((x)&(-x))
using namespace std;
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
inline ll getgcd(ll x,ll y){return !x?y:getgcd(y%x,x);}
inline ll getlcm(ll x,ll y){return x/getgcd(x,y)*y;}
inline ll qpow(int x,int y,int p){
ll re=1;
while(y){
if(y&1)re=(re*x)%p;
y>>=1,x=(x*x)%p;
}
return re;
}
const int maxn=2e3+6;
char s[maxn],t[maxn];int n;
vector<int>a;
void shift(int x){
if(!x)return;
reverse(s,s+n);
reverse(s+x,s+n);
a.pb(x);
}
int main()
{
rep(i,0,n-1){
int j=i;
while(j<n&&s[j]!=t[n-i-1])j++;
if(j==n){puts("-1");return 0;}
shift(n);shift(j);shift(1);
}
printf("%d\n",a.size());
for(int i=0;i<a.size();i++)printf("%d ",a[i]);
return 0;
}