标签:style blog color io 2014 for re c
A. Game With Sticks
题意:博弈题,就是给你一个n+m个棒子,n个棒子横着放,m个棒子竖着放,这样形成一个有交叉点的图子,要你每次操作能拿交叉点,相交的那2个的棒子可以拿走,直到最后不能拿走棒子的那一人输了
AC代码:
#include<stdio.h> int main() { int n,m; scanf("%d %d",&n,&m); n=n<m?n:m; if(n%2==0) printf("Malvika\n"); else printf("Akshat\n"); return 0; }
#include<stdio.h> long a[100010]; int main() { int n,flag=1,l=1,r=1,i; a[0]=0; scanf("%d",&n); scanf("%ld",&a[1]); if(n==1) { printf("yes\n"); printf("1 1\n"); } else { for(i=2;i<=n;i++) { scanf("%ld",&a[i]); if(flag==1&&a[i-1]>a[i]) { l=i-1; flag=0; } if(a[i]==a[i-1]) flag=-1; if(flag==0&&a[i]>a[i-1]) { r=i-1; flag=2; } if(flag==2&&a[i-1]>a[i]) flag=-1; } if(flag==-1)printf("no\n"); else if(flag==1) { printf("yes\n"); printf("1 1\n"); } else { if(r==1&&l==1) { printf("yes\n"); printf("1 %d",n); } else if(r==1) { if(a[n]<a[l-1]) { printf("no\n"); } else { printf("yes\n"); printf("%d %d",l,n); } } else { if(a[r]<a[l-1]||a[l]>a[r+1]) { printf("no\n"); } else { printf("yes\n"); printf("%d %d",l,r); } } } } return 0; }
Codeforces Round #258 (Div. 2),布布扣,bubuko.com
Codeforces Round #258 (Div. 2)
标签:style blog color io 2014 for re c
原文地址:http://blog.csdn.net/u012313382/article/details/38105147