UVa Problem Solution: 10188 - Automated Judge Script
来源:互联网 发布:js 键值对 编辑:程序博客网 时间:2024/04/29 23:07
Not a difficult problem. Just catenate the lines together and compare the correct and submitted answer will do it well. Unfortunately, the problem statement is misleading: I get WA consistently with a "linesize" of 102, however, it becomes AC when I switch to 110.
Code:
- /*************************************************************************
- * Copyright (C) 2008 by liukaipeng *
- * liukaipeng at gmail dot com *
- *************************************************************************/
- /* @JUDGE_ID 00000 10188 C++ "Automated Judge Script" */
- #include <cstdlib>
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- using namespace std;
- int const linecount = 100;
- int const linesize = 110;
- int judge(char *correct, int ncorrect, char *submit, int nsubmit)
- {
- int result = 0;
- if (ncorrect != nsubmit) {
- result = 1;
- }
- int p = 0;
- if (result == 0) {
- for (; correct[p] != '/0' || submit[p] != '/0'; ++p) {
- if (correct[p] != submit[p]) {
- result = 1;
- break;
- }
- }
- }
- int c = p, s = p;
- if (result == 1) {
- for (; correct[c] != '/0' || submit[s] != '/0'; ) {
- for (; correct[c] != '/0' && !isdigit(correct[c]); ++c) {}
- for (; submit[s] != '/0' && !isdigit(submit[s]); ++s) {}
- if (correct[c++] != submit[s++]) {
- result = 2;
- break;
- }
- }
- }
- return result;
- }
- int main(int argc, char *argv[])
- {
- #ifndef ONLINE_JUDGE
- filebuf in, out;
- cin.rdbuf(in.open((string(argv[0]) + ".in").c_str(), ios_base::in));
- cout.rdbuf(out.open((string(argv[0]) + ".out").c_str(), ios_base::out));
- #endif
- char const *results[] = {
- "Accepted",
- "Presentation Error",
- "Wrong Answer",
- };
- for (int run = 1; ; ++run) {
- char buf[10];
- cin.getline(buf, 10);
- int ncorrect = atoi(buf);
- if (0 == ncorrect) {
- break;
- }
- char correct[linecount*linesize] = {0};
- for (int i = 0, pos = 0; i < ncorrect; ++i, pos += cin.gcount()-1) {
- cin.getline(correct + pos, linesize);
- }
- cin.getline(buf, 10);
- int nsubmit = atoi(buf);
- char submit[linecount*linesize] = {0};
- for (int i = 0, pos = 0; i < nsubmit; ++i, pos += cin.gcount()-1) {
- cin.getline(submit + pos, linesize);
- }
- int result = judge(correct, ncorrect, submit, nsubmit);
- cout << "Run #" << run << ": " << results[result] << "/n";
- }
- return 0;
- }
- UVa Problem Solution: 10188 - Automated Judge Script
- uva-10188-Automated Judge Script
- UVa 10188 Automated Judge Script
- uva 10188 - Automated Judge Script
- UVa 10188 Automated Judge Script
- UVA 10188 Automated Judge Script
- UVa 10188 - Automated Judge Script
- UVa Problem 10188 Automated Judge Script (自动评测脚本)
- UVaOJ 10188 - Automated Judge Script
- UVa10188 - Automated Judge Script
- Automated Judge Script
- uva10188 - Automated Judge Script
- 110305 Automated Judge Script
- uva10188 - Automated Judge Script
- (挑战编程_3_5)Automated Judge Script
- programming-challenges Automated Judge Script (110305) 题解
- 【ACM】Solution of UVA 489-Hangman Judge
- UVa Problem Solution: 10189 - Minesweeper
- [转贴]Visual C++常用数据类型转换详解
- 堆:欢乐和痛苦
- epoll为什么这么快
- [转贴] 定义const 型指针
- [转帖]解析#pragma指令
- UVa Problem Solution: 10188 - Automated Judge Script
- XHTML 1.0:标记新的开端
- 删除Symbian模拟器中测试程序的方法
- Firefox - 更新 - 3.0.4
- [转贴] C++类型转换操作符(cast operator)
- 块级元素和内联元素
- Delphi的指针
- reactos操作系统实现(2)
- 敏捷开发