CF #281 div2
2014-12-04 13:49:24
总结:水了那么久codeforces,还是没有什么大进步,果然还是不够努力啊。。。
A、B、C、D都不难,E数学题,没做了。。
A:此题就坑在要判断是否是第一次被出示黄牌。
1 /************************************************************************* 2 > File Name: a.cpp 3 > Author: Nature 4 > Mail: 564374850@qq.com 5 > Created Time: Wed 03 Dec 2014 11:00:13 PM CST 6 ************************************************************************/ 7 8 #include <cstdio> 9 #include <cstring> 10 #include <cstdlib> 11 #include <cmath> 12 #include <vector> 13 #include <map> 14 #include <set> 15 #include <stack> 16 #include <queue> 17 #include <iostream> 18 #include <algorithm> 19 using namespace std; 20 #define lp (p << 1) 21 #define rp (p << 1|1) 22 #define getmid(l,r) (l + (r - l) / 2) 23 #define MP(a,b) make_pair(a,b) 24 typedef long long ll; 25 const int INF = 1 << 30; 26 27 int t,n,num; 28 char n1[100],n2[100]; 29 int c1[200],c2[200]; 30 31 int main(){ 32 char t1[5],t2[5]; 33 int a; 34 scanf("%s",n1); 35 scanf("%s",n2); 36 scanf("%d",&n); 37 for(int i = 1; i <= n; ++i){ 38 scanf("%d%s%d%s",&t,t1,&num,t2); 39 if(t1[0] == 'h'){ 40 if(t2[0] == 'y') 41 c1[num]++; 42 else 43 c1[num] += 2; 44 if(c1[num] == 2 || c1[num] == 3){ 45 c1[num] += 10; 46 printf("%s %d %d\n",n1,num,t); 47 } 48 } 49 else{ 50 if(t2[0] == 'y') 51 c2[num]++; 52 else 53 c2[num] += 2; 54 if(c2[num] == 2 || c2[num] == 3){ 55 c2[num] += 10; 56 printf("%s %d %d\n",n2,num,t); 57 } 58 } 59 } 60 return 0; 61 }
B:逗比的模拟题,注意下long long即可。
1 /************************************************************************* 2 > File Name: b.cpp 3 > Author: Nature 4 > Mail: 564374850@qq.com 5 > Created Time: Wed 03 Dec 2014 11:14:48 PM CST 6 ************************************************************************/ 7 8 #include <cstdio> 9 #include <cstring> 10 #include <cstdlib> 11 #include <cmath> 12 #include <vector> 13 #include <map> 14 #include <set> 15 #include <stack> 16 #include <queue> 17 #include <iostream> 18 #include <algorithm> 19 using namespace std; 20 #define lp (p << 1) 21 #define rp (p << 1|1) 22 #define getmid(l,r) (l + (r - l) / 2) 23 #define MP(a,b) make_pair(a,b) 24 typedef long long ll; 25 const int INF = 1 << 30; 26 27 int n; 28 ll s1,s2,v1[200010],v2[200010]; 29 int c1,c2,rear; 30 31 int main(){ 32 int a; 33 scanf("%d",&n); 34 for(int i = 1; i <= n; ++i){ 35 scanf("%d",&a); 36 if(a > 0){ 37 v1[++c1] = a; 38 s1 += a; 39 } 40 else{ 41 v2[++c2] = -a; 42 s2 += -a; 43 } 44 if(i == n) rear = a; 45 } 46 if(s1 > s2) 47 printf("first\n"); 48 else if(s1 < s2) 49 printf("second\n"); 50 else{ 51 int sz = max(c1,c2); 52 for(int i = 1; i <= sz; ++i){ 53 if(v1[i] == v2[i]) 54 continue; 55 if(v1[i] > v2[i]){ 56 printf("first\n"); 57 return 0; 58 } 59 else{ 60 printf("second\n"); 61 return 0; 62 } 63 } 64 if(rear > 0) printf("first\n"); 65 else printf("second\n"); 66 } 67 return 0; 68 }
C:离散化后暴力扫描,比赛逗比的想简单了。
1 /************************************************************************* 2 > File Name: c.cpp 3 > Author: Nature 4 > Mail: 564374850@qq.com 5 > Created Time: Thu 04 Dec 2014 01:15:11 AM CST 6 ************************************************************************/ 7 8 #include <cstdio> 9 #include <cstring> 10 #include <cstdlib> 11 #include <cmath> 12 #include <vector> 13 #include <map> 14 #include <set> 15 #include <stack> 16 #include <queue> 17 #include <iostream> 18 #include <algorithm> 19 using namespace std; 20 #define lp (p << 1) 21 #define rp (p << 1|1) 22 #define getmid(l,r) (l + (r - l) / 2) 23 #define MP(a,b) make_pair(a,b) 24 typedef long long ll; 25 const int INF = 1 << 30; 26 27 int n,m,c,c1,c2,v1[200010],v2[200010]; 28 int vp[400010],p1[400010],p2[400010]; 29 30 int main(){ 31 scanf("%d",&n); 32 for(int i = 1; i <= n; ++i){ 33 ++c1; 34 scanf("%d",&v1[c1]); 35 vp[++c] = v1[c1]; 36 } 37 scanf("%d",&m); 38 for(int i = 1; i <= m; ++i){ 39 ++c2; 40 scanf("%d",&v2[c2]); 41 vp[++c] = v2[c2]; 42 } 43 sort(vp + 1,vp + c + 1); 44 int sz = unique(vp + 1,vp + c + 1) - vp; 45 for(int i = 1; i <= n; ++i){ 46 int val = lower_bound(vp + 1,vp + sz + 1,v1[i]) - vp; 47 p1[val]++; 48 } 49 for(int i = 1; i <= m; ++i){ 50 int val = lower_bound(vp + 1,vp + sz + 1,v2[i]) - vp; 51 p2[val]++; 52 } 53 int ans1 = 3 * n,ans2 = 3 * m,s1 = 3 * n,s2 = 3 * m,tmax = 3 * (n - m); 54 for(int i = 0; i <= sz; ++i){ 55 s1 -= p1[i]; 56 s2 -= p2[i]; 57 if(s1 - s2 > tmax){ 58 ans1 = s1; 59 ans2 = s2; 60 tmax = s1 - s2; 61 } 62 } 63 printf("%d:%d\n",ans1,ans2); 64 return 0; 65 }
D:这个。。。猜猜就出来了,尽量把图走完,如果图中格子数为偶数,那么白先黑后两个两个占掉,最后是白吃黑。如果为奇数,那么黑吃白。
1 /************************************************************************* 2 > File Name: d.cpp 3 > Author: Nature 4 > Mail: 564374850@qq.com 5 > Created Time: Wed 03 Dec 2014 11:36:45 PM CST 6 ************************************************************************/ 7 8 #include <cstdio> 9 #include <cstring> 10 #include <cstdlib> 11 #include <cmath> 12 #include <vector> 13 #include <map> 14 #include <set> 15 #include <stack> 16 #include <queue> 17 #include <iostream> 18 #include <algorithm> 19 using namespace std; 20 #define lp (p << 1) 21 #define rp (p << 1|1) 22 #define getmid(l,r) (l + (r - l) / 2) 23 #define MP(a,b) make_pair(a,b) 24 typedef long long ll; 25 const int INF = 1 << 30; 26 27 int main(){ 28 int n; 29 scanf("%d",&n); 30 if(n % 2 == 0){ 31 printf("white\n"); 32 printf("1 2\n"); 33 } 34 else{ 35 printf("black\n"); 36 } 37 return 0; 38 }