A. Avengers, The

留坑。

B. Black Widow

将所有数的所有约数插入set,然后求mex。

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int>pi;
const int mod=1e9+7;
int n,i,x;
set<int>T;
inline void add(int n){
for(int i=1;i<=n/i;i++)if(n%i==0){
T.insert(i);
T.insert(n/i);
}
}
int main(){
scanf("%d",&n);
while(n--)scanf("%d",&x),add(x);
for(i=1;;i++)if(T.find(i)==T.end())break;
printf("%d",i);
return 0;
}

  

C. Chitauri

海盗分金问题,倒着递推即可。

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pi;
int n,k;
int rep[1020];
int a[1020][1020];
int main(){
while(scanf("%d%d",&n,&k)!=EOF){
for(int i=1;i<=n;i++){
if(i==1){
a[i][1]=k;
continue;
}
vector<pi>V;
for(int j=1;j<i;j++){
V.push_back(pi(a[i-1][j]+1,-j));
}
sort(V.begin(),V.end());
int ned=i/2,sum=0;
if(i%2==0)ned--;
for(int j=0;j<ned;j++){
sum+=V[j].first;
}
if(k<sum){
a[i][i]=-1;
for(int j=1;j<i;j++)a[i][j]=a[i-1][j];
}
else{
for(int j=1;j<=i;j++)a[i][j]=0;
a[i][i]=k-sum;
for(int j=0;j<ned;j++){
a[i][-V[j].second]=V[j].first;
}
}
}
for(int i=n;i>=1;i--){
if(a[i][i]!=-1){
for(int j=1;j<=i;j++)rep[j]=a[i][j];
break;
}
else rep[i]=-1;
}
for(int i=n;i>=1;i--)printf("%d%c",rep[i],i==1?'\n':' ');
}
}

  

D. Dr. Banner

DP,$f[i][j]$表示填了$i$层,最后一层是$j$的方案数,状态数只有$O(n)$个,转移用前缀和优化。

时间复杂度$O(n)$。

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int>pi;
const int mod=1e9+7;
int dp[2][100020];
void up(int &x,int y){
x+=y;if(x>=mod)x-=mod;
}
int main(){
int n;
scanf("%d",&n);
int lim=n,cs=0;
dp[0][n]=1;
int ans=1;
for(;lim;lim/=2,cs^=1){
memset(dp[cs^1],0,sizeof dp[cs^1]);
for(int i=1;i<=lim;i++){
up(dp[cs^1][i/2],dp[cs][i]);
}
for(int i=lim/2;i>=1;i--){
dp[cs^1][i]=(dp[cs^1][i]+dp[cs^1][i+1])%mod;
up(ans,dp[cs^1][i]);
}
}
printf("%d\n",ans);
}

  

E. Egocentric Loki

根据题意判断是否有点介于三角形和外接圆之间即可。

#include <bits/stdc++.h>
using namespace std ; const int MAXN = 100005 ;
const double eps = 1e-8 ; int sgn ( double x ) {
return ( x > eps ) - ( x < -eps ) ;
} struct P {
double x , y ;
P () {}
P ( double x , double y ) : x ( x ) , y ( y ) {}
P operator + ( const P& p ) const {
return P ( x + p.x , y + p.y ) ;
}
P operator - ( const P& p ) const {
return P ( x - p.x , y - p.y ) ;
}
double operator * ( const P& p ) const {
return x * p.y - y * p.x ;
}
P operator * ( const double& v ) const {
return P ( x * v , y * v ) ;
}
P operator / ( const double& v ) const {
return P ( x / v , y / v ) ;
}
P rot90 () {
return P ( -y , x ) ;
}
void input () {
scanf ( "%lf%lf" , &x , &y ) ;
}
double len () {
return x * x + y * y ;
}
} a[MAXN][3] ; int n ; double cross ( P a , P b ) {
return a * b ;
} int line_intersection ( P a , P b , P p , P q , P& o ) {
double U = cross ( p - a , q - p ) ;
double D = cross ( b - a , q - p ) ;
o = a + ( b - a ) * ( U / D ) ;
return 1 ;
} int check ( P a , P b , P c , P p ) {
int t1 = sgn ( cross ( p - b , p - a ) ) ;
int t2 = sgn ( cross ( p - c , p - b ) ) ;
int t3 = sgn ( cross ( p - a , p - c ) ) ;
if ( t1 >= 0 && t2 >= 0 && t3 >= 0 ) return 1 ;
if ( t1 <= 0 && t2 <= 0 && t3 <= 0 ) return 1 ;
return 0 ;
} void solve () {
for ( int i = 1 ; i <= n ; ++ i ) {
for ( int j = 0 ; j < 3 ; ++ j ) {
a[i][j].input () ;
}
}
for ( int i = 1 ; i <= n ; ++ i ) {
P x1 = ( a[i][0] + a[i][1] ) / 2 ;
P y1 = ( a[i][0] - a[i][1] ) ;
y1 = y1.rot90 () ;
y1 = y1 + x1 ;
P x2 = ( a[i][1] + a[i][2] ) / 2 ;
P y2 = ( a[i][1] - a[i][2] ) ;
y2 = y2.rot90 () ;
y2 = y2 + x2 ;
P o ;
line_intersection ( x1 , y1 , x2 , y2 , o ) ;
double r = ( o - a[i][0] ).len () ;
for ( int j = 1 ; j <= n ; ++ j ) if ( i != j ) {
for ( int k = 0 ; k < 3 ; ++ k ) {
if ( ( o - a[j][k] ).len () + eps < r ) {
if ( check ( a[i][0] , a[i][1] , a[i][2] , a[j][k] ) == 0 ) {
printf ( "NO\n" ) ;
return ;
}
}
}
}
}
printf ( "YES\n" ) ;
} int main () {
while ( ~scanf ( "%d", &n ) ) solve () ;
return 0 ;
}

  

F. Fury

求出SCC,每个SCC可以用一个环连接,外面DAG部分贪心选边即可。

#include <bits/stdc++.h>
using namespace std ; typedef pair < int , int > P ; const int N = 305 ;
const int M = 1000005 ; P b[M] ;
vector < int > G[N] , V[N] ;
int n , m ;
int Q[N] , t ;
int S[N] , siz ;
int vis[N] ;
int ans ;
int scc[N];
int fa[N] ; namespace BZOJ {
int i , j , x , y , d[N],g[N],g2[N],v[M],v2[M],nxt[M],nxt2[M],ed,h,t,q[N];
bitset<N>f[N];
void add(int x,int y){d[y]++;v[++ed]=y;nxt[ed]=g[x];g[x]=ed;}
void add2(int x,int y){v2[++ed]=y;nxt2[ed]=g2[x];g2[x]=ed;}
void solve(int n){
for(i=1;i<=n;++i)f[i][i]=1;
for(ed=0,i=h=1;i<=n;++i)if(!d[i])q[++t]=i;
while(h<=t)for(i=g[x=q[h++]];i;add2(v[i],x),i=nxt[i])if(!(--d[v[i]]))q[++t]=v[i];
for(i=1;i<=n;++i)for(j=g2[x=q[i]];j;f[x]|=f[v2[j]],j=nxt2[j]){
if(!f[x][v2[j]])b[++ans]=P(fa[v2[j]],fa[x]);
}
}
} void dfs1 ( int u ) {
vis[u] = 1 ;
for ( int i = 0 ; i < G[u].size () ; ++ i ) if ( !vis[G[u][i]] ) dfs1 ( G[u][i] ) ;
Q[++ t] = u ;
} void dfs2 ( int u , int f ) {
scc[u] = f ;
vis[u] = 0 ;
S[++ siz] = u ;
for ( int i = 0 ; i < V[u].size () ; ++ i ) if ( vis[V[u][i]] ) dfs2 ( V[u][i] , f ) ;
} void solve () {
for ( int i = 1 ; i <= n ; ++ i ) {
G[i].clear () ;
}
for ( int i = 1 ; i <= m ; ++ i ) {
int u , v ;
scanf ( "%d%d" , &u , &v ) ;
G[u].push_back ( v ) ;
V[v].push_back ( u ) ;
}
for ( int i = 1 ; i <= n ; ++ i ) if ( !vis[i] ) dfs1 ( i ) ;
int cnt = 0 ;
ans = 0 ;
for ( int i = n ; i >= 1 ; -- i ) if ( vis[Q[i]] ) {
++ cnt ;
siz = 0 ;
fa[cnt] = Q[i] ;
dfs2 ( Q[i] , cnt ) ;
if ( siz > 1 ) {
for ( int j = 1 ; j < siz ; ++ j ) {
b[++ ans] = P ( S[j] , S[j + 1] ) ;
}
b[++ ans] = P ( S[siz] , S[1] ) ;
}
}
for ( int i = 1 ; i <= n ; ++ i ) {
//printf ( "scc[%d] = %d\n" , i , scc[i] ) ;
}
for ( int i = 1 ; i <= n ; ++ i ) {
for ( int j = 0 ; j < G[i].size () ; ++ j ) {
int v = G[i][j] ;
if ( scc[i] != scc[v] ) {
BZOJ :: add ( scc[i] , scc[v] ) ;
}
}
}
BZOJ :: solve ( cnt ) ;
printf ( "%d %d\n" , n , ans ) ;
for ( int i = 1 ; i <= ans ; ++ i ) {
printf ( "%d %d\n" , b[i].first , b[i].second ) ;
}
} int main () {
while ( ~scanf ( "%d%d", &n , &m ) ) solve () ;
return 0 ;
}

  

G. Groot

猜对题意即可。

#include <bits/stdc++.h>
using namespace std ; const int MAXN = 100005 ; char s[MAXN] ; void solve () {
int cnt = 0 ;
for ( int i = 0 ; s[i] ; ++ i ) {
if ( s[i] == '!' ) ++ cnt ;
}
if ( !cnt ) printf ( "Pfff\n" ) ;
else {
printf ( "W" ) ;
while ( cnt -- ) printf ( "o" ) ;
printf ( "w\n" ) ;
}
} int main () {
while ( fgets ( s , MAXN , stdin ) ) solve () ;
return 0 ;
}

  

H. Heimdall

留坑。

I. Iron Man

留坑。

J. Jarvis

任意一条边$(u,v)$的增量都可以表示成$d[1][v]-d[1][u]$,高斯消元即可。

时间复杂度$O(n^3)$。

K. KSON

大模拟。

 


总结:

  • 要尽快适应读题场。

XVI Open Cup named after E.V. Pankratiev. GP of Ekaterinburg的更多相关文章

  1. XVI Open Cup named after E.V. Pankratiev. GP of Ukraine

    A. Associated Vertices 首先求出SCC然后缩点,第一次求出每个点能到的点集,第二次收集这些点集即可,用bitset加速,时间复杂度$O(\frac{nm}{64})$. #inc ...

  2. XVI Open Cup named after E.V. Pankratiev. GP of Peterhof

    A. (a, b)-Tower 当指数大于模数的时候用欧拉定理递归计算,否则直接暴力计算. #include<cstdio> #include<algorithm> #incl ...

  3. XVI Open Cup named after E.V. Pankratiev. GP of Siberia

    A. Passage 枚举两个点,看看删掉之后剩下的图是否是二分图. #include <bits/stdc++.h> using namespace std ; const int MA ...

  4. XVI Open Cup named after E.V. Pankratiev. GP of Eurasia

    A. Nanoassembly 首先用叉积判断是否在指定向量右侧,然后解出法线与给定直线的交点,再关于交点对称即可. #include<bits/stdc++.h> using names ...

  5. XVI Open Cup named after E.V. Pankratiev. GP of SPB

    A. Bubbles 枚举两个点,求出垂直平分线与$x$轴的交点,答案=交点数+1. 时间复杂度$O(n^2\log n)$. #include<cstdio> #include<a ...

  6. XVI Open Cup named after E.V. Pankratiev. GP of Ekaterinburg--I.Iron man

    n个服务器,k类任务,每个服务器完成一个任务都有特定的花费$cost_{i,j}$,但是你设置好某台机器去完成某项任务时他只能去完成这类任务,除非你可以花费$C$去更改配置.第$i$天要求去完成$q_ ...

  7. XV Open Cup named after E.V. Pankratiev. GP of Tatarstan

    A. Survival Route 留坑. B. Dispersed parentheses $f[i][j][k]$表示长度为$i$,未匹配的左括号数为$j$,最多的未匹配左括号数为$k$的方案数. ...

  8. XVII Open Cup named after E.V. Pankratiev. GP of SPb

    A. Array Factory 将下标按前缀和排序,然后双指针,维护最大的右边界即可. #include<cstdio> #include<algorithm> using ...

  9. XIV Open Cup named after E.V. Pankratiev. GP of SPb

    A. Bracket Expression 直接按题意模拟即可. 时间复杂度$O(n)$. #include<stdio.h> #include<algorithm> #inc ...

随机推荐

  1. 11个审查Linux是否被入侵的方法

    11个审查Linux是否被入侵的方法 一.检查系统日志 lastb命令 检查系统错误登陆日志,统计IP重试次数 二.检查系统用户 1.cat /etc/passwd 查看是否有异常的系统用户 2.gr ...

  2. Ubuntu安装SSH服务器故障分析及解决办法(错误1:E:软件包 openssh-server 还没有可供安装的候选者,错误2:E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系)

    •    微博: 小样儿老师2015 Windows下做Linux开发需要SSH强大功能的支持.安装SSH的过程会出现了很多问题,看完这篇文章可以让你少走些弯路,PS:折腾一下午的成果. Ubuntu ...

  3. EXCEL 2010学习笔记 —— VLOOKUP函数 嵌套 MATCH 函数

    match index vlookup 等函数都是查找引用类函数,需要查找的时候关键变量只有两个,区域+位置,区域的选择注意是否需要锁定,位置的确定可以通过输入特定的行号和列号. match() ma ...

  4. 泛型DAO与泛型Service

    泛型Dao与Service 看了几个帖子,泛型Dao与Service的主要目的就是要减少重复代码.具体的说明如下: 1. 定义一个BaseDao接口,此接口包含了一些通用的DAO操作,例如:增加.删除 ...

  5. BZOJ 2083: [Poi2010]Intelligence test

    Description 问一个序列是不是起始序列的子序列. Sol 二分. 直接维护每个数出现的位置,二分一个最小的就行. Code /******************************** ...

  6. linux下vmware的安装、物理分区使用及卸载

    1.安装 先下载安装文件VMware-Workstation-Full-12 在命令行下执行下载的文件安装即可(需要root权限) wget https://download3.vmware.com/ ...

  7. centos 6.7 搭建tornado + nginx + supervisor的方法(已经实践)

    首先,本来不想写这篇博客了,但是我测试了很多网上的例子包括简书的,全不行,我总结原因是自己太笨,搞了俩个晚上,后来决定,自己还是写一篇记录下来,保证自己以后使用 环境: centos6.7 64 py ...

  8. 各种开源Android 系统定制

    MIUI MIUI是由小米科技开发的Android装置系统.2016年2月24日,MIUI全球用户超过1.7亿.部分开源代码托管在GitHub 官网 国际网站 http://miuiandroid.c ...

  9. 【原创】node+express+socket搭建一个实时推送应用

    技术背景 Web领域的实时推送技术,也被称作Realtime技术.这种技术要达到的目的是让用户不需要刷新浏览器就可以获得实时更新. 应用场景: 监控系统:后台硬件热插拔.LED.温度.电压发生变化 即 ...

  10. [原创]用windows7连接windows2003的终端服务器时,出现"由于这台计算机没有远程桌面客户端访问许可证,远程会话被中断"的问题

    用windows7连接windows2003的终端服务器时,出现"由于这台计算机没有远程桌面客户端访问许可证,远程会话被中断"的问题,原因是终端服务器授权方式设置为了"每 ...