【AOJ 2400】You Are the Judge
問題
You Are the Judge | Aizu Online Judge
ソースコード
#include <iostream> #include <string> #include <cstring> #include <algorithm> using namespace std; #define rep(i,n) for(int i = 0 ; i < n ; i++) struct SCORE{ int id, ac, penalty; bool operator < (const SCORE& another) const{ if(ac == another.ac && penalty == another.penalty){ return id < another.id; }else if(ac == another.ac){ return penalty < another.penalty; }else{ return ac > another.ac; } } }; int main(){ int t, p, r; int submit[51][51]; SCORE score[51]; while(cin >> t >> p >> r, t || p || r){ int tID, pID, time; string msg; /*初期化*/ memset(submit, 0, sizeof(submit)); rep(i,t+1){ score[i].id = i+1; score[i].ac = score[i].penalty = 0; } rep(i,r){ cin >> tID >> pID >> time >> msg; if(msg == "CORRECT"){ score[tID-1].ac++; score[tID-1].penalty += (time + 1200 * submit[tID][pID]); }else{ submit[tID][pID]++; } } sort(score, score+t); rep(i, t){ cout << score[i].id << " " << score[i].ac << " " << score[i].penalty << '\n'; } } }
始めてoperatorを使った。