Codeforces Round #281 (Div. 2) A. Vasya and Football(模拟)
简单题,却犯了两个错误导致WA了多次。
第一是程序容错性不好,没有考虑到输入数据中可能给实际已经罚下场的人再来牌,这种情况在system测试数据里是有的。。。
二是chronologically这个词没注意,其实如果输入是按时间顺序的,就直接在线处理就行了,用不着int team1[110][110],team2[110][110]两个数组。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<cctype>
#include<sstream>
using namespace std;
#define pii pair<int,int>
#define LL long long int
const int eps=1e-;
const int INF=;
const int maxn=+;
char t1[],t2[];
int n,t,m;
int team1[][],team2[][];
int r1[],r2[];
char team,card;
int main()
{
//freopen("in2.txt","r",stdin);
//freopen("out.txt","w",stdout);
scanf("%s%s",t1,t2);
scanf("%d",&n);
for(int i=; i<n; i++)
{
scanf("%d",&t);
getchar();
scanf("%c",&team);
getchar();
scanf("%d",&m);
getchar();
scanf("%c",&card);
getchar();
if(team=='a')
{
if(card=='y')
{
r2[m]++;
if(r2[m]==)
team2[t][m]=;
}
else
{
if(r2[m]<)
{
r2[m]=;
team2[t][m]=;
}
}
}
else
{
if(card=='y')
{
r1[m]++;
if(r1[m]==)
team1[t][m]=;
}
else
{
if(r1[m]<)
{
r1[m]=;
team1[t][m]=;
}
}
}
}
for(int i=; i<=; i++)
{
for(int j=; j<=; j++)
{
if(team1[i][j]==)
{
printf("%s %d %d\n",t1,j,i);
break;
}
else if(team2[i][j]==)
{
printf("%s %d %d\n",t2,j,i);
break;
}
}
}
//fclose(stdin);
//fclose(stdout);
return ;
}
我的渣代码
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm> using namespace std; const int max_n = , inf = ; int n, f[][max_n];
string a[]; int main() {
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
cin >> a[] >> a[] >> n;
while (n--) {
int t, num, q, c;
char c1, c2;
cin >> t >> c1 >> num >> c2;
if (c1 == 'h') {
q = ;
} else {
q = ;
}
if (c2 == 'y') {
c = ;
} else {
c = ;
}
if (f[q][num] < ) {
f[q][num] += c;
if (f[q][num] >= ) {
cout << a[q] << " " << num << " " << t << endl;
}
}
}
return ;
}
BigBag大神的优美代码
Codeforces Round #281 (Div. 2) A. Vasya and Football(模拟)的更多相关文章
- Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力水题
A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力
A. Vasya and Football Vasya has started watching football games. He has learned that for some foul ...
- Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题
B. Vasya and Wrestling 题目连接: http://codeforces.com/contest/493/problem/B Description Vasya has becom ...
- Codeforces Round #281 (Div. 2) D. Vasya and Chess 水
D. Vasya and Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分
C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #281 (Div. 2) D. Vasya and Chess 镜面对称 博弈论
D. Vasya and Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 暴力水题
C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #281 (Div. 2) D. Vasya and Chess 博弈
D. Vasya and Chess Vasya decided to learn to play chess. Classic chess doesn't seem interesting to ...
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball 排序
C. Vasya and Basketball Vasya follows a basketball game and marks the distances from which each te ...
随机推荐
- HTTP首部信息说明
1.Accept:告诉WEB服务器自己接受什么介质类型,*/* 表示任何类型,type/* 表示该类型下的所有子类型,type/sub-type.2.Accept-Charset:浏览器申明自己接收的 ...
- Django_Form表单补充
Form表单 问题1: 注册页面输入为空,报错:keyError:找不到password def clean(self): print("---",self.cleaned_da ...
- 无法处理文件 MainForm.resx,因为它位于 Internet 或受限区域中,或者文件上具有 Web 标记。要想处理这些文件,请删除 Web 标记
无法处理文件 MainForm.resx,因为它位于 Internet 或受限区域中,或者文件上具有 Web 标记.要想处理这些文件,请删除 Web 标记 问题: 由于文件锁定,VS不能正常读取. 解 ...
- android camera jni调用
http://www.mamicode.com/info-detail-1002139.html how to compile library of native camera for androi ...
- 【Head First Servlets and JSP】笔记10:请求分派(RequestDispatcher)
1.让其它组件接管全部请求. package com.example.web; import com.example.model.BeerExpert; import javax.servlet.*; ...
- package.json字段简要解析
name 必填 应用名称 version 必填 应用版本 description 选填 应用描述,多用于搜索,在npm search 时可以用到 keywords 选填 应用关键字,也多用于搜索 sc ...
- iOS_数据存取(二)
本节内容目录: 一.SQLite3 二.Core Data 一.SQlite3 SQLite3是⼀款开源的嵌入式关系型数据库,可移植性好.易使用.内存开销小SQLite3是⽆类型的,意味着你可以保存任 ...
- [Python]基于CNN的MNIST手写数字识别
目录 一.背景介绍 1.1 卷积神经网络 1.2 深度学习框架 1.3 MNIST 数据集 二.方法和原理 2.1 部署网络模型 (1)权重初始化 (2)卷积和池化 (3)搭建卷积层1 (4)搭建卷积 ...
- Kubernetes addon-manager
Addon-manager 附加组件管理器(Addon-manager)是运行在 Kubernetes 集群 Master 节点.用来管理附加组件(Addons)的服务.它管理着 $ADDON_PAT ...
- Go 功能测试与性能测试
1.功能测试 calcTriangle.go // 需要被测试的函数 func calcTriangle(a, b int) int { return int(math.Sqrt(float64(a* ...