RT,这是我的 80 分代码:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define F(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define R(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
using namespace std;
string attempter;
char s[1007];
int kase = 1;
string getname(char* s) {
int len = strlen(s);
string ans = "";
F(i, 0, len - 1) {
if(s[i] == ' ' && s[i + 1] == ':') return ans;
ans += s[i];
}
}
int getat(char* s) {
int len = strlen(s), pl = 0, num = 0;
F(i, 0, len - 1)
if(s[i] == '@') pl = i, num++;
if(num != 1) return 0;
return pl;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("P1580.in", "r", stdin);
freopen("P1580.out", "w", stdout);
#endif
while(1) {
gets(s);
int len = strlen(s);
if(len < 2) {
kase--;
break;
}
string name = getname(s); int plofat = getat(s);
if(name == attempter) {
cout << "Successful @" << attempter << " attempt";
return 0;
}
else if(!plofat) {
cout << "Unsuccessful @" << attempter << " attempt\n";
printf("%d\n", kase);
cout << name;
return 0;
}
if(kase == 1) {
attempter = "yyy loves ";
F(i, plofat + 11, len - 1) {
if(s[i] == ' ') break;
attempter += s[i];
}
}
kase++;
}
cout << "Unsuccessful @" << attempter << " attempt\n";
printf("%d\n", kase);
cout << "Good Queue Shape";
}
这是我的 60 分代码:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define F(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define R(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
using namespace std;
string attempter;
char s[1007];
int kase = 1;
string getname(char* s) {
int len = strlen(s);
string ans = "";
F(i, 0, len - 1) {
if(s[i] == ' ' && s[i + 1] == ':') return ans;
ans += s[i];
}
}
int getat(char* s) {
int len = strlen(s), pl = 0, num = 0;
F(i, 0, len - 1)
if(s[i] == '@') pl = i, num++;
if(num != 1) return 0;
return pl;
}
int main() {
while(1) {
gets(s);
int len = strlen(s);
if(len < 2) {
kase--;
break;
}
string name = getname(s); int plofat = getat(s);
if(name == attempter) {
cout << "Successful @" << attempter << " attempt\n";
return 0;
}
else if(!plofat) {
cout << "Unsuccessful @" << attempter << " attempt\n";
printf("%d\n", kase);
cout << name << endl;
return 0;
}
if(kase == 1) {
attempter = "yyy loves ";
F(i, plofat + 11, len - 1) {
if(s[i] == ' ') break;
attempter += s[i];
}
} else {
string atp = "yyy loves ";
F(i, plofat + 11, len - 1) {
if(s[i] == ' ') break;
atp += s[i];
}
if(atp != attempter) {
cout << "Unsuccessful @" << attempter << " attempt\n";
printf("%d\n", kase);
cout << name << endl;
return 0;
}
}
kase++;
}
cout << "Unsuccessful @" << attempter << " attempt\n";
printf("%d\n", kase);
cout << "Good Queue Shape";
}
敢问是哪里错了导致我越改分越低?
还有,read ASCII 13 是什么意思?
真·萌新,底下讨论区不要 fAke 谢谢。