📄 2313.cpp
字号:
/* This Code is Submitted by wywcgs for Problem 2313 on 2006-08-07 at 22:28:18 */
#include <cstdio>
#include <algorithm>
using namespace std;
const int GN = 64;
const int L = 64;
inline int sgn(int a) { return a ? abs(a)/a : 0; }
class Gamer {
public:
char name[L];
int o, w, s, a, b;
void make(int co) { o = co; gets(name); s = w = 0; }
void guess() { scanf("%d : %d", &a, &b); }
int score(int, int);
bool operator <(const Gamer&) const;
void show() const { printf("%d %d %s\n", s, w, name); }
};
int Gamer::score(int ta, int tb) {
int ts;
if(a == ta && b == tb) ts = 3;
else if(sgn(a-b) == sgn(ta-tb)) ts = 1;
else ts = 0;
s += ts; return ts;
}
bool Gamer::operator <(const Gamer& g) const {
if(s != g.s) return s > g.s;
else if(w != g.w) return w > g.w;
else return o < g.o;
}
int main()
{
Gamer g[GN];
int t, T, i;
scanf("%d", &T);
for(t = 0; t < T; t++) {
int n, r, R; scanf("%d %d\n", &n, &R);
for(i = 0; i < n; i++) g[i].make(i);
for(r = 0; r < R; r++) {
int sc[GN] = { 0 }, p, P;
scanf("%d", &P);
for(p = 0; p < P; p++) {
int ta, tb; scanf("%d : %d", &ta, &tb);
for(i = 0; i < n; i++) { g[i].guess(); sc[i] += g[i].score(ta, tb); }
}
int best = 0;
for(i = 0; i < n; i++) best = max(best, sc[i]);
for(i = 0; i < n; i++)
if(sc[i] == best) g[i].w++;
}
sort(g, g+n);
printf("Scenario #%d:\n", t+1);
for(i = 0; i < n; i++) g[i].show();
putchar('\n');
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -