http://codeforces.com/gym/101309/attachments
过了6题,I题是紫书上原题都没有写出来,队友写炸了,比赛结束5分钟后改出来了(疯狂甩锅)
感觉NEERC的题目都不错,感觉都是可写的题
A:
solved by sdn
/*
ID: oodt
PROG:
LANG:C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
G:交互题,对称取即可
solved by lyy
/*
ID: oodt
PROG:
LANG:C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
K:
solved by wyq
#include
using namespace std;
#define ll long long
struct Edge
{
int to,next;
}edge[2000005];
int head[10005],tot;
int max1=0;
int color[10005];
int used[100005];
void init()
{
tot=0;
memset(head,-1,sizeof(head));
memset(color,-1,sizeof(color));
}
void addedge(int u,int v)
{
edge[tot].to=v;
edge[tot].next=head[u];
head[u]=tot++;
}
void bfs(int now)
{
int i,v;
for(i=head[now];i!=-1;i=edge[i].next)
{
v=edge[i].to;
if(color[v]==-1)continue;
used[color[v]]=1;
}
for(i=1;i<=max1;i++)
{
if(used[i]==0)
{
color[now]=i;
break;
}
}
for(i=head[now];i!=-1;i=edge[i].next)
{
v=edge[i].to;
if(color[v]==-1)continue;
used[color[v]]=0;
}
for(i=head[now];i!=-1;i=edge[i].next)
{
v=edge[i].to;
if(color[v]!=-1)continue;
bfs(v);
}
}
int deg[10005];
int main()
{
freopen("kgraph.in","r",stdin);
freopen("kgraph.out","w",stdout);
init();
int n,m,i,x,y;
scanf("%d%d",&n,&m);
for(i=1;i<=m;i++)
{
scanf("%d%d",&x,&y);
addedge(x,y);
addedge(y,x);
deg[x]++;
deg[y]++;
}
for(i=1;i<=n;i++)
{
if(deg[i]>max1)max1=deg[i];
}
if(max1%2==0)max1++;
printf("%d\n",max1);
bfs(1);
for(i=1;i<=n;i++)
printf("%d\n",color[i]);
return 0;
}
E:简单dp
solved by lyy
#include
using namespace std;
#define ll long long
int n,m;
struct st
{
int id;
int data;
};
ll dp[4005][4005];
int w[4005][4005];
st a[4005];
st b[4005];
int ans[4005];
bool cmp(st a,st b)
{
return a.data=dp[i-1][j]) w[i][j]=j;
else w[i][j]=j-1;
}
}
dfs(n,m);
printf("%I64d\n",dp[n][m]);
for (int i=1;i<=n;i++)
{
printf("%d",ans[i]);
if (i!=n) printf(" ");
}
printf("\n");
return 0;
}
D:用凸包乱搞,不过感觉是不是我想复杂了
solved by lyy ans wyq
#include
using namespace std;
#define ll long long
#define eps 1e-8
int sgn(double x)
{
if(fabs(x)eps;
}
const int MAXN=10005;
int Stack[MAXN],top;
double dist(Point a,Point b)
{
return sqrt((a-b)*(a-b));
}
bool _cmp(Point p1,Point p2)
{
double tmp=(p1-point[0])^(p2-point[0]);
if(sgn(tmp)>0)return true;
else if(sgn(tmp)==0 && sgn(dist(p1,point[0])-dist(p2,point[0]))<=0)
return true;
else return false;
}
void Graham(int n)
{
Point p0;
int k=0;
p0=point[0];
for(int i=1;ipoint[i].y)||(p0.y==point[i].y && p0.x>point[i].x))
{
p0=point[i];
k=i;
}
}
swap(point[k],point[0]);
sort(point+1,point+n,_cmp);
Stack[0]=0;
Stack[1]=1;
top=2;
for(int i=2;i1 && sgn((point[Stack[top-1]]-point[Stack[top-2]])^(point[i]-point[Stack[top-2]]))<=0)
{
top--;
}
Stack[top++]=i;
}
}
int main()
{
freopen("dome.in","r",stdin);
freopen("dome.out","w",stdout);
int n,i,j;
double x,y,z;
bool p;
double xmax=0;
double ymax=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%lf%lf%lf",&x,&y,&z);
point[i].x=sqrt(x*x+y*y);
point[i].y=z;
if(point[i].x>xmax)xmax=point[i].x;
if(point[i].y>ymax)ymax=point[i].y;
}
point[n+1].x=xmax;
point[n+1].y=0;
point[n+2].x=0;
point[n+2].y=ymax;
point[0].x=0;
point[0].y=0;
Point point0;
point0.x=0;
point0.y=0;
n=n+3;
Graham(n);
double minsqu,minh,minr,nowh,nowr;
minsqu=1e30;
for(i=0;i
F:数学题,并不算太难,筛一筛素因子即可
solved by lyy
#include
using namespace std;
#define ll long long
#define maxn 10007
int n,m;
int a[10010];
int pri[maxn+5];
vector v[10010];
int p[1500];
int s[10010][1300];
vector >ans;
void getPrime()
{
int i,j;
for (i=2;i<=maxn;i++)
{
if (pri[i]==0) pri[++pri[0]]=i;
for (j=1;j<=pri[0] && pri[j]<=maxn/i;j++)
{
pri[pri[j]*i]=1;
if (i%pri[j]==0) break;
}
}
}
vector go(int x)
{
int o=x;
vector ans;
for (int i=1;i<=pri[i];i++)
{
if (x%pri[i]==0)
{
while (x%pri[i]==0)
{
s[o][i]++;
ans.push_back(i);
x/=pri[i];
}
}
}
return ans;
}
bool can(int x)
{
for (int i=1;i<=pri[0];i++)
{
if (p[i]0) x=min(x,p[i]/s[c][i]);
}
ans.push_back({c,x});
for (int i=1;i<=pri[0];i++)
{
p[i]-=s[c][i]*x;
}
}
printf("%d\n",ans.size());
for (auto x:ans)
{
printf("%d %d\n",x.first,x.second);
}
}
return 0;
}