日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

UVa 10258 - Contest Scoreboard

發(fā)布時間:2024/4/15 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 UVa 10258 - Contest Scoreboard 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

  題目大意:關(guān)于acm競賽排名的題目,對于參賽者首先按做出的題目排名,然后是罰時,最后是編號。

  多關(guān)鍵字域排序問題。

1 #include <cstdio> 2 #include <cstring> 3 #include <cctype> 4 #include <iostream> 5 #include <algorithm> 6 using namespace std; 7 8 struct Cont 9 { 10 int id, num, t_penalty; 11 int penalty[10]; 12 bool solved[10], join; 13 bool operator < (const Cont & c) const 14 { 15 if (num != c.num) return num > c.num; 16 if (t_penalty != c.t_penalty) return t_penalty < c.t_penalty; 17 return id < c.id; 18 } 19 } cont[110]; 20 21 int main() 22 { 23 #ifdef LOCAL 24 freopen("in", "r", stdin); 25 #endif 26 int T; 27 scanf("%d", &T); 28 getchar(); 29 char str[100]; 30 gets(str); 31 while (T--) 32 { 33 memset(cont, 0, sizeof(cont)); 34 for (int i = 1; i <= 100; i++) 35 cont[i].id = i; 36 while (gets(str) && str[0]) 37 { 38 int c, p, time; 39 char ch; 40 sscanf(str, "%d%d%d", &c, &p, &time); 41 for (int i = strlen(str)-1; i >= 0; i++) 42 if (isupper(str[i])) 43 { 44 ch = str[i]; 45 break; 46 } 47 cont[c].join = true; 48 if (ch == 'C') 49 { 50 if (!cont[c].solved[p]) 51 { 52 cont[c].num++; 53 cont[c].penalty[p] += time; 54 cont[c].solved[p] = true; 55 } 56 } 57 else if (ch == 'I') 58 { 59 if (!cont[c].solved[p]) 60 cont[c].penalty[p] += 20; 61 } 62 } 63 for (int i = 1; i <= 100; i++) 64 for (int j = 1; j <= 9; j++) 65 if (cont[i].solved[j]) 66 cont[i].t_penalty += cont[i].penalty[j]; 67 sort(cont+1, cont+101); 68 for (int i = 1; i <= 100; i++) 69 if (cont[i].join) 70 printf("%d %d %d\n", cont[i].id, cont[i].num, cont[i].t_penalty); 71 if (T) printf("\n"); 72 } 73 return 0; 74 } View Code

  要注意的是,當一道題目正確提交后,以后對該題目的提交都對結(jié)果無影響。一直注意這點了,卻忘了當一道題最終沒有正確提交時,以前的錯誤提交是不計算罰時的,因為這個糾結(jié)了好長時間,WA的好慘...看別人代碼時心里還在想“干嘛多次一舉保存每個題的罰時?”,忽然就明白了,是我錯了...

轉(zhuǎn)載于:https://www.cnblogs.com/xiaobaibuhei/p/3297740.html

總結(jié)

以上是生活随笔為你收集整理的UVa 10258 - Contest Scoreboard的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。