Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #ifdef ERFANUL007
- #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
- template < typename Arg1 >
- void __f(const char* name, Arg1&& arg1){
- cout << name << " = " << arg1 << std::endl;
- }
- template < typename Arg1, typename... Args>
- void __f(const char* names, Arg1&& arg1, Args&&... args){
- const char* comma = strchr(names, ',');
- cout.write(names, comma - names) << " = " << arg1 <<" | ";
- __f(comma+1, args...);
- }
- #else
- #define debug(...)
- #endif
- bool participated[101];
- bool solved[101][10];
- int penalty[101][10];
- bool cmp(pair< pair< int, int >, int > a, pair< pair< int, int >, int > b){
- if(a.first.second != b.first.second) return a.first.second > b.first.second;
- if(a.second != b.second) return a.second < b.second;
- return a.first.first < b.first.first;
- }
- int main(){
- #ifdef ERFANUL007
- clock_t tStart = clock();
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- int t, cs=0;
- cin >> t;
- getchar();
- getchar();
- while(t--){
- memset(participated, 0, sizeof(participated));
- memset(solved, 0, sizeof(solved));
- memset(penalty, 0, sizeof(penalty));
- if(cs++) cout << '\n';
- string s;
- while(getline(cin, s) && s.size()){
- //debug(s);
- stringstream ss(s);
- int team;
- ss >> team;
- int problem;
- ss >> problem;
- int time;
- ss >> time;
- string status;
- ss >> status;
- participated[team] = 1;
- if(status[0] == 'C' && !solved[team][problem]){
- solved[team][problem] = true;
- penalty[team][problem] += time;
- }
- else if(status[0] == 'I' && !solved[team][problem]){
- penalty[team][problem] += 20;
- }
- }
- vector< pair< pair< int, int >, int > > scoreboard;
- for(int i=1; i<=100; i++){
- if(!participated[i]) continue;
- int problem = 0, pen = 0;
- for(int j=1; j<=9; j++){
- if(!solved[i][j]) continue;
- problem++;
- pen += penalty[i][j];
- }
- scoreboard.push_back(make_pair(make_pair(i, problem), pen));
- }
- sort(scoreboard.begin(), scoreboard.end(), cmp);
- for(auto it : scoreboard){
- cout << it.first.first << ' ' << it.first.second << ' ' << it.second << '\n';
- }
- }
- #ifdef ERFANUL007
- fprintf(stderr, ">>> Runtime : %.9f\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement