• [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
    ",++t,ans[p]);
    		memset(a,0,sizeof a);
    		memset(b,0,sizeof b);
    	}
    	return 0;
    }
    
  • 相关阅读:
    wireshake抓包,飞秋发送信息,python
    python问题:IndentationError:expected an indented block错误解决《转》
    560. Subarray Sum Equals K
    311. Sparse Matrix Multiplication
    170. Two Sum III
    686. Repeated String Match
    463. Island Perimeter
    146. LRU Cache
    694. Number of Distinct Islands
    200. Number of Islands
  • 原文地址:https://www.cnblogs.com/Mrsrz/p/7379698.html
Copyright © 2020-2023  润新知