Codeforces Round #368

A题是给出一个字符矩阵，判断是不是彩色图像（有CMY）。水~~~~

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
int n,m;
using namespace std;
int main(){
cin>>n>>m;
char c;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>c;
if(c=='C'||c=='M'||c=='Y'){
printf("#Color");
return 0;
}
}
}
printf("#Black&White");
return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
int n;
long long ans1,ans2;
int main(){
scanf("%d",&n);
if(n<=2){
printf("-1");
return 0;
}
if(n%2==1){
long long x=(n-1)/2;
ans1=2*x*x+2*x;
ans2=ans1+1;
}
if(n%2==0){
long long x=n/2;
ans1=x*x-1;
ans2=x*x+1;
}

printf("%I64d %I64d",ans1,ans2);
return 0;
} 

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct edge{
int u,v,w;
}e[1000001];
int n,m,k,ck[100001],Ans=0x3f3f3f3f;
int cmp(edge x,edge y){
return x.w<y.w;
}
int main(){
memset(ck,0,sizeof(ck));
scanf("%d%d%d",&n,&m,&k);
int u,v,w;
for(int i=1;i<=m;i++){
scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
}
int x;
for(int i=1;i<=k;i++){
scanf("%d",&x);
ck[x]=1;
}
if(k==0&&k==n){
printf("-1");
return 0;
}
sort(e+1,e+m+1,cmp);
for(int i=1;i<=m;i++){
if(ck[e[i].u]&&!ck[e[i].v]||!ck[e[i].u]&&ck[e[i].v]){
printf("%d",e[i].w);
return 0;
}
}
printf("-1");
return 0;
} 

Menci：40分钟A3T
zzs:30分钟A3T
Chentsuei：30分钟A3T

#include<cstring>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

#define ll long long
char c;
bool flag;
{a=0;do c=getchar();while(c!='-'&&(c<'0'||c>'9'));c=c=='-'?flag=true,getchar():c;while(c<='9'&&c>='0')a=(a<<3)+(a<<1)+c-'0',c=getchar();a=flag?flag=false,-a:a;}
inline int min(int a,int b){return a<b?a:b;}
inline int max(int a,int b){return a>b?a:b;}
inline int Min(double &a,double b){return a<b?a:a=b;}
inline int Max(int &a,int b){return a>b?a:a=b;}

struct Node
{
Node *lc,*rc;
int l,r;
int val;
int sum;
Node *Val;
};
Node *Root[200001];

inline void up(Node *A)
{
if(A->l==A->r)A->sum=A->val;
else
{
A->sum=A->lc->sum+A->rc->sum;
if(A->val)A->sum=A->r-A->l+1-A->sum;
}
}

inline void up2(Node *A)
{
if(A->l==A->r)
A->sum=A->Val->sum;
else
{
A->sum=A->lc->sum+A->rc->sum;
}
}

Node *N;

Node *Build(int l,int r)
{
Node *A=new Node;
A->l=l,A->r=r;
A->val=0;
A->sum=0;
A->lc=A->rc=NULL;
if(l==r)
return A;
A->lc=Build(l,l+r>>1);
A->rc=Build((l+r>>1)+1,r);
return A;
}

Node *New(Node *A)
{
Node *R=new Node;
*R=*A;
return R;
}

Node *Build2(int l,int r)
{
Node *A=new Node;
A->l=l,A->r=r;
A->val=0;
A->sum=0;
A->lc=A->rc=NULL;
if(l==r)
{
A->Val=New(N);
return A;
}
A->lc=Build2(l,l+r>>1);
A->rc=Build2((l+r>>1)+1,r);
return A;

}

Node *Modify(Node *Cur,int l,int data,int Sum)
{
Node *N=New(Cur);
Sum^=Cur->val;
if(Cur->l!=Cur->r)
{
if(Cur->lc->r>=l)N->lc=Modify(Cur->lc,l,data,Sum);
else N->rc=Modify(Cur->rc,l,data,Sum);
return up(N),N;
}
else
{
if(Sum&&data)return up(N),N;
if(Sum&&!data)
{
Sum^=Cur->val;
return N->val=Sum?1:0,up(N),N;
}
if(data)
{
Sum^=Cur->val;
return N->val=Sum?0:1,up(N),N;
}

return up(N),N;
}
}

Node *Modify2(Node *Cur,int l,int lly,int data)
{
if(Cur->l==Cur->r)
{
Node *N=New(Cur);
N->Val=Modify(Cur->Val,lly,data,0);
return up2(N),N;
}
Node *N=New(Cur);
if(l<=Cur->lc->r)N->lc=Modify2(Cur->lc,l,lly,data);
else N->rc=Modify2(Cur->rc,l,lly,data);
return up2(N),N;
}

Node *Rotato(Node *Cur,int l)
{
if(Cur->l==Cur->r)
{
Node *N=New(Cur);
N->Val=New(N->Val);
N->Val->val^=1;
up(N->Val);
return up2(N),N;
}
Node *N=New(Cur);
if(l<=Cur->lc->r)N->lc=Rotato(Cur->lc,l);
else N->rc=Rotato(Cur->rc,l);
return up2(N),N;
}

int n,m,q;
int main()
{
N=Build(1,m);
Root[0]=Build2(1,n);
for(int i=1;i<=q;i++)
{
if(op==1)
{
int u,v;
Root[i]=Modify2(Root[i-1],u,v,1);
}
else if(op==2)
{
int u,v;
Root[i]=Modify2(Root[i-1],u,v,0);
}
else if(op==3)
{
int u;
Root[i]=Rotato(Root[i-1],u);
}
int Ans=Root[i]->sum;
printf("%d\n",Ans);
}

return 0;
}



Codeforces Round #368 (DIV 2)

2016-08-21 08:23:53

【CodeForces】CodeForces Round #464 (Div. 2) 题解

2018-02-18 11:05:43

Codeforces Round #471 div.2 ABC题解

2018-03-24 14:16:58

【Codeforces Testing Round #4】Codeforces 147B Smile House

2016-12-05 19:53:02

Codeforces Round #444 (Div. 2)-贪心&尺取-Ratings and Reality Shows

2017-11-11 20:11:11

【解题报告】 Educational Codeforces Round 19

2017-04-16 17:16:52

Educational Codeforces Round #41 (D&E)

2018-04-05 10:38:15

Educational Codeforces Round 42 E 贪心

2018-04-11 11:57:41

解题报告：Educational Codeforces Round 24 D,E,F

2017-07-01 14:07:43

Educational Codeforces Round 36 (Rated for Div. 2) 题解

2018-01-13 23:16:24

不良信息举报

Codeforces Round #368