Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* BISMILLAHIR-RAHMANIR-RAHIM
- ____________________________________
- | |
- | SHANTO_SUST_SWE-19_029 |
- |____________________________________|
- */
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
- #define pb push_back
- #define Pi acos(-1)
- #define r0 return 0
- #define endl "\n"
- #define show(x) cout << x << endl
- #define take(x) cin >> x
- #define debug 1
- int main()
- {
- int T, t = 0;
- cin >> T;
- getchar();
- getchar();
- string s;
- int solved[101][11]; //if nth one is solved
- int penalty[101][11];
- int submitted[101]; //if submitted
- int correct[101]; //total solved
- int tot_pen[101];
- int index[101];
- int id, p, n;
- int i, j, len, temp;
- string ID, pen, num;
- char ch;
- while(T--) {
- t++;
- for(i = 0; i < 101; i++) {
- for(j = 0; j < 11; j++) {
- solved[i][j] = 0;
- penalty[i][j] = 0;
- }
- submitted[i] = 0;
- correct[i] = 0;
- tot_pen[i] = 0;
- index[i] = i;
- }
- while(1) {
- getline(cin, s);
- if(s.size() == 0) {
- break;
- }
- //till now OKAY!
- len = s.size();
- //ID
- for(i = 0; i < len; i++) {
- if(s[i] == ' ') {
- break;
- }
- ID.pb(s[i]);
- }
- i++;
- //Problem Number
- for( ; ; i++) {
- if(s[i] == ' ') {
- break;
- }
- num.pb(s[i]);
- }
- i++;
- //Penalty
- for( ; ; i++) {
- if(s[i] == ' ') {
- break;
- }
- pen.pb(s[i]);
- }
- i++;
- ch = s[len-1];
- int m = 1;
- //calculating id
- m = 1;
- id = 0;
- for(i = ID.size() - 1; i >= 0; i--) {
- id += (s[i] - '0') * m;
- m *= 10;
- }
- submitted[id] = 1;
- //calculating n
- m = 1;
- n = 0;
- for(i = num.size() - 1; i >= 0; i--) {
- n += (num[i] - '0') * m;
- m *= 10;
- }
- //calculating p
- m = 1;
- p = 0;
- for(i = pen.size() - 1; i >= 0; i--) {
- p += (pen[i] - '0') * m;
- m *= 10;
- }
- if( ch == 'R' || ch == 'U' || ch == 'E' ) {
- ID.clear();
- num.clear();
- pen.clear();
- continue;
- }
- else if(ch == 'C') {
- if(solved[id][n] != 1) {
- penalty[id][n] += p;
- }
- solved[id][n] = 1;
- }
- else if(ch == 'I') {
- if(solved[id][n] != 1) {
- penalty[id][n] += 20;
- }
- }
- ID.clear();
- num.clear();
- pen.clear();
- }
- //counting tot_penalty and correct array
- for(i = 1; i < 101; i++) {
- if(submitted[i]) {
- for(j = 1; j < 11; j++) {
- if(solved[i][j] == 1) {
- correct[i]++;
- tot_pen[i] += penalty[i][j];
- }
- }
- }
- }
- //Now we will sort
- //most solved (correct)
- for(i = 1; i < 101; i++) {
- for(j = i + 1; j < 101; j++) {
- if(correct[index[i]] < correct[index[j]]) {
- temp = index[i];
- index[i] = index[j];
- index[j] = temp;
- }
- }
- }
- //penalty
- int l = 1, r, j, k;
- for(i = 1; i < 101; i++) {
- if(i == 100) {
- r = 101;
- for(j = l; j < r; j++) {
- for(k = j + 1; k < r; k++) {
- if(tot_pen[index[j]] > tot_pen[index[k]]) {
- //switch
- cout << "j,k = " << index[j] << "," << index[k] << endl;
- temp = index[k];
- index[k] = index[j];
- index[j] = temp;
- }
- }
- }
- }
- else if(correct[index[l]] != correct[index[i]]) {
- r = i;
- for(j = l; j < r; j++) {
- for(k = j + 1; k < r; k++) {
- if( (tot_pen[index[j]] > tot_pen[index[k]]) ) {
- //switch
- temp = index[k];
- index[k] = index[j];
- index[j] = temp;
- }
- }
- }
- l = r;
- }
- }
- //index
- l = 1;
- for(i = 1; i < 101; i++) {
- if(i == 100) {
- r = 101;
- for(j = l; j < r; j++) {
- for(k = j + 1; k < r; k++) {
- if( (correct[index[j]] == correct[index[k]]) &&
- (index[j] > index[k]) ) {
- //switch
- temp = index[k];
- index[k] = index[j];
- index[j] = temp;
- }
- }
- }
- }
- else if(tot_pen[index[l]] != tot_pen[index[i]]) {
- r = i;
- for(j = l; j < r; j++) {
- for(k = j + 1; k < r; k++) {
- if( (correct[index[j]] == correct[index[k]]) &&
- (index[j] > index[k]) ) {
- //switch
- temp = index[k];
- index[k] = index[j];
- index[j] = temp;
- }
- }
- }
- l = r;
- }
- }
- //sorted
- if(t != 1) {
- cout << endl;
- }
- for(i = 1; i < 101; i++) {
- if(submitted[index[i]]) {
- cout << index[i] << " " << correct[index[i]] << " " << tot_pen[index[i]] << endl;
- }
- }
- }
- r0;
- }
- //ALHAMDULILLAH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement