[UVa10188]Automated Judge Script
题目大意:叫你写一个判断答案的系统。
解题思路:模拟即可。AC条件为,答案条数相等,所有字符相等。PE条件为,答案条数可能不等,所有数字字符相等。其他为WA。
UVa现在的C++已经不支持gets了,于是CE了几发。C++11仍然支持,所以下面代码需在C++11下评测。
C++ Code:
#include<cstdio>
#include<cctype>
#include<cstring>
using namespace std;
int n,m;
char a[102][130],b[102][130],s[3],ap[20000],bp[20000];
const char ans[][30]={"Accepted","Wrong Answer","Presentation Error"};
int p;
bool ac(){
if(n!=m)return false;
for(int i=0;i<=n;++i)
for(int j=0;a[i][j]||b[i][j];++j)
if(a[i][j]!=b[i][j])return false;
return true;
}
bool pe(){
int cnta=0,cntb=0;
for(int i=1;i<=n;++i)
for(int j=0;a[i][j];++j)if(isdigit(a[i][j]))ap[++cnta]=a[i][j];
for(int i=1;i<=m;++i)
for(int j=0;b[i][j];++j)if(isdigit(b[i][j]))bp[++cntb]=b[i][j];
if(cnta!=cntb)return false;
for(int j=1;j<=cnta;++j)if(ap[j]!=bp[j])return false;
return true;
}
int main(){
int t=0;
while(scanf("%d",&n)&&n){
gets(s);
for(int i=1;i<=n;++i)gets(a[i]);
scanf("%d",&m);
gets(s);
for(int i=1;i<=m;++i)gets(b[i]);
if(ac())p=0;else
if(pe())p=2;else
p=1;
printf("Run #%d: %s\n",++t,ans[p]);
memset(a,0,sizeof a);
memset(b,0,sizeof b);
}
return 0;
}
[UVa10188]Automated Judge Script的更多相关文章
- UVa 10188 - Automated Judge Script
题目:给你一些题目的输出结果,推断是AC,PE还是WA. 分析:模拟. 依照题意模拟就可以,注意PE条件为全部数字字符出现顺序同样就可以. 说明:想起非常多年前写的OJ的后台判题程序了╮(╯▽╰)╭. ...
- (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO
http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...
- ACM训练计划step 1 [非原创]
(Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成 ...
- 算法竞赛入门经典+挑战编程+USACO
下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...
- linux commands
abrt-cli --since ;查看abrt捕捉的异常 alias ;别名,alias rm='rm -i':使用“ \rm ” 使用原命令 alsamixer ;图形音量调节,q 增加左声道, ...
- 一个很简单的php留言板。。。。搭建在sae上的。。。
我在sae上搭建了一个个人简历的页面: 有兴趣的可以访问 http://671coder.sinaapp.com/ 在做下面一个简单的留言板的时候,卡了我很久,虽然完全没用过php..但是还是最后勉 ...
- 【Python】Camera拍照休眠唤醒测试
#!/usr/bin/python # -*- coding: UTF-8 -*- import os import sys import time rebootCount = int(input(& ...
- Expect Command And How To Automate Shell Scripts Like Magic
In the previous post, we talked about writing practical shell scripts and we saw how it is easy to w ...
- Linux Expect自动交互脚本
https://likegeeks.com/expect-command/ In the previous post, we talked about writing practical shell ...
随机推荐
- UVA10082-WERTYU(紫书例题3.2)
A common typing error is to place the hands on the keyboard one row to the right of the correct posi ...
- 在centos里安装Nginx
(1)下载Nginx的RPM包 wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx ...
- mysql局域网服务搭建
首先配置电脑Mysql环境变量 新建 Mysql服务配置 CMD >命令 : mysql -u root -p 4. 创建用户 Mysql 用户权限分配 5 重启服务 如果还不能访问就一定是你的 ...
- pytorch 4 regression 回归
import torch import torch.nn.functional as F import matplotlib.pyplot as plt # torch.manual_seed(1) ...
- crm 系统项目(一) 登录,注册,校验
crm 系统项目(一) 登录,注册,校验 首先创建一个Django项目,关于配置信息不多说,前面有~ models.py文件下创建需要的表格信息,之后导入数据库 from django.db impo ...
- JavaScript中的“闭包”
什么是JavaScript中的“闭包”?举一个例子. 闭包是一个内部函数,它可以访问外部(封闭)函数的作用域链中的变量.闭包可以访问三个范围内的变量;具体来说: (1)变量在其自己的范围内, (2)封 ...
- SQL SERVER-约束
NOT NULL - 指示某列不能存储 NULL 值. UNIQUE - 保证某列的每行必须有唯一的值. PRIMARY KEY - NOT NULL 和 UNIQUE 的结合.确保某列(或两个列多个 ...
- 在 RedHat/CentOS 7.x 中使用 nmcli 命令管理网络
在 RedHat/CentOS 7.x 中使用 nmcli 命令管理网络 学习了:https://linux.cn/article-5410-1.html#3_3613 http://www.linu ...
- 根据数据表自动生成javaBean
package fanshe; import java.io.File; import java.io.FileWriter; import java.io.IOException; import j ...
- 关闭 sftp
vi /etc/ssh/sshd_config 注释掉这行Subsystem sftp /usr/libexec/openssh/sftp-server /etc/rc.d/init.d/ss ...