主题:第58次编程比赛初测 & 最终结果
雨中飞燕 [专家分:18980] 发布于 2007-07-30 23:38:00
[color=0000FF]初测结果:[/color]
我直接复制原作者的代码测试的,结果发现这样的话没有一份代码能通过测试
绝大多数代码是WA,少数代码是CE,TLE和RE
现在开始进行放宽限制的测试
如果你觉得你的代码需要更正的,请跟帖,跟帖更正限时一天之内
更正的代码和原来的代码只能相差最多两行并且在20字节以内,
否则更正代码视作无效
[color=0000FF]最终结果:[/color]
本题测试数据一共四个Test,能全部通过前四组的代码的作者有:
flyee (-2)
AntiMicrosoft (-1)
从速度上来说,这两份代码都很好。
从代码结构和算法上来看,两人用的思路也差不多。
所以我决定flyee和AntiMicrosoft两人同时胜出作为本次比赛的冠军
最后更新于:2007-08-01 00:36:00
回复列表 (共42个回复)
21 楼
AntiMicrosoft [专家分:3740] 发布于 2007-07-31 22:16:00
#include <stdio.h>
void cmp(char *p, char *q)
{
int pt[128]={0}, qt[128]={0}, a=0, b=0, *t, i;
while(*p && *q){
if(*p==*q) a++;
pt[*p++]++; qt[*q++]++;
}
if(*p || *q){
t = *p?pt:qt;
p = *p?p:q;
while(*p) t[*p++]++;
}
for(i=0; i<128; i++)
b += pt[i]>qt[i]?qt[i]:pt[i];
printf("%dA%dB\n", a, b-a);
}
int main()
{
char s1[10001], s2[10001]; //改成10001,汗一个,长度是10000....
while(scanf("%s %s", s1, s2)!=EOF)
cmp(s1, s2);
}
22 楼
walshy [专家分:0] 发布于 2007-07-31 23:05:00
#include <iostream>
#include <string>
using namespace std;
const int MAX_CHAR_LEN = 10001;
int main()
{
char str1[MAX_CHAR_LEN],str2[MAX_CHAR_LEN];
while(cin>>str1>>str2)
{
int x=0,y=0;
for(int i=0;i<MAX_CHAR_LEN;i++)
for(int j=0; j<MAX_CHAR_LEN;j++)
{
if( str1[i]== '\0'|| str2[j]== '\0' )
break;
else
if( str1[i]==str2[j] )
if(i==j) x++;
else y++;
}
cout<<x<<"A"<<y<<"B"<<endl;
}
return 0;
}
23 楼
S石溪X [专家分:290] 发布于 2007-08-01 00:16:00
// 6.cpp : Defines the entry point for the console application.
//使用VC2005编译器
#include "stdafx.h"
#include<iostream>
#include <time.h>
#include <stdio.h>
using namespace std;
int main()
{
char str1[1001],str2[1001];
while(cin>>str1>>str2){
int a=0,b=0,c=0;
int i=0;
while(1){
if(str1[i]=='\0'||str2[i]=='\0')break;
if(str1[i]==str2[i]) {
str1[i]='@';
str2[i]='@';
a++;
}
i++;
}
int q,p;
q=0;
while(1){
if(str1[q]=='\0') break;
p=0;
while(1){
if(p==q){
p++;continue;
}
if(str2[p]=='\0')break;
if(str1[q]==str2[p]) {
if(str1[q]=='@') ;
else b++;
}
p++;
}
q++;
}
cout<<a<<"A"<<b<<"B";
}
}
24 楼
S石溪X [专家分:290] 发布于 2007-08-01 00:18:00
// 6.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#include <time.h>
#include <stdio.h>
using namespace std;
int main()
{
char str1[1001],str2[1001];
while(cin>>str1>>str2){
int a=0,b=0,c=0;
int i=0;
while(1){
if(str1[i]=='\0'||str2[i]=='\0')break;
if(str1[i]==str2[i]) {
str1[i]='@';
str2[i]='@';
a++;
}
i++;
}
int q,p;
q=0;
while(1){
if(str1[q]=='\0') break;
p=0;
while(1){
if(p==q){
p++;continue;
}
if(str2[p]=='\0')break;
if(str1[q]==str2[p]) {
if(str1[q]=='@') ;
else b++;
}
p++;
}
q++;
}
cout<<a<<"A"<<b<<"B";
}
}
25 楼
S石溪X [专家分:290] 发布于 2007-08-01 00:18:00
// 6.cpp : Defines the entry point for the console application.
//使用VC2005编译器
#include "stdafx.h"
#include<iostream>
#include <time.h>
#include <stdio.h>
using namespace std;
int main()
{
char str1[1001],str2[1001];
while(cin>>str1>>str2){
int a=0,b=0,c=0;
int i=0;
while(1){
if(str1[i]=='\0'||str2[i]=='\0')break;
if(str1[i]==str2[i]) {
str1[i]='@';
str2[i]='@';
a++;
}
i++;
}
int q,p;
q=0;
while(1){
if(str1[q]=='\0') break;
p=0;
while(1){
if(p==q){
p++;continue;
}
if(str2[p]=='\0')break;
if(str1[q]==str2[p]) {
if(str1[q]=='@') ;
else b++;
}
p++;
}
q++;
}
cout<<a<<"A"<<b<<"B";
}
}
26 楼
雨中飞燕 [专家分:18980] 发布于 2007-08-01 00:23:00
Name: "[color=Blue]S石溪X[/color]" Problem ID "[color=Blue]43[/color]"
Submit Time: 2007/8/01-00:18
[font=宋体][color=red]VC8++: Compile Warning:
Line(11) : warning C4127: conditional expression is constant
Line(24) : warning C4127: conditional expression is constant
Line(27) : warning C4127: conditional expression is constant
Line(9) : warning C4189: 'c' : local variable is initialized but not referenced
[/color]
Test 1: [color=red]Wrong Answer[/color]
────────────────
Problem ID 43
Test Result [color=red]Wrong Answer[/color]
Total Time Null
Total Memory 84 Kb
Code Length 865 Bytes
[/font]
27 楼
S石溪X [专家分:290] 发布于 2007-08-01 00:23:00
其实使用函数调用会延长很多时间的。
28 楼
S石溪X [专家分:290] 发布于 2007-08-01 00:23:00
你们应该知道的啊
29 楼
flyee [专家分:340] 发布于 2007-08-01 12:23:00
第二份应该就可以过的:估计是因为你输入部分用的cin>>str1>>str2才超时的
30 楼
廖增祥 [专家分:3930] 发布于 2007-08-01 15:42:00
[quote]第二份应该就可以过的:估计是因为你输入部分用的cin>>str1>>str2才超时的[/quote]
为什么输入的部分用 cin>>str1>>str2 就会超时呢?
谁能解释一下啊~~~~
我来回复