1. 程式人生 > >PTA PAT Judge 【模擬題,未完待續】

PTA PAT Judge 【模擬題,未完待續】

The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to generate the ranklist for PAT.

Input Specification:

Each input file contains one test case. For each case, the first line contains 3 positive integers, NNN (≤104\le 10^4≤10
​4
​​), the total number of users, KKK (≤5\le 5≤5), the total number of problems, and MMM (≤105\le 10^5≤10
​5
​​), the total number of submittions. It is then assumed that the user id’s are 5-digit numbers from 00001 to NNN, and the problem id’s are from 1 to KKK. The next line contains KKK positive integers p[i] (i=1, …, KKK), where p[i] corresponds to the full mark of the i-th problem. Then MMM lines follow, each gives the information of a submittion in the following format:
user_id problem_id partial_score_obtained

where partial_score_obtained is either −1-1−1 if the submittion cannot even pass the compiler, or is an integer in the range [0, p[problem_id]]. All the numbers in a line are separated by a space.

Output Specification:

For each test case, you are supposed to output the ranklist in the following format:
rank user_id total_score s[1] … s[K]

where rank is calculated according to the total_score, and all the users with the same total_score obtain the same rank; and s[i] is the partial score obtained for the i-th problem. If a user has never submitted a solution for a problem, then “-” must be printed at the corresponding position. If a user has submitted several solutions to solve one problem, then the highest score will be counted.

The ranklist must be printed in non-decreasing order of the ranks. For those who have the same rank, users must be sorted in nonincreasing order according to the number of perfectly solved problems. And if there is still a tie, then they must be printed in increasing order of their id’s. For those who has never submitted any solution that can pass the compiler, or has never submitted any solution, they must NOT be shown on the ranklist. It is guaranteed that at least one user can be shown on the ranklist.

Sample Input:
7 4 20
20 25 25 30
00002 2 12
00007 4 17
00005 1 19
00007 2 25
00005 1 20
00002 2 2
00005 1 15
00001 1 18
00004 3 25
00002 2 25
00005 3 22
00006 4 -1
00001 2 18
00002 1 20
00004 1 15
00002 4 18
00001 3 4
00001 4 2
00005 2 -1
00004 2 0

Sample Output:
1 00002 63 20 25 - 18
2 00005 42 20 0 22 -
2 00007 42 - 25 - 17
2 00001 42 18 18 4 2
5 00004 40 15 0 25 -

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define INF 0x3f3f3f
#define pi acos(-1.0)
#define MAX 100010
#define mod 9973
#define ll long long


/*


n, k,   m;
人 題目 提交



*/

const int N =1e5+10;
struct asd{
    int name;
    int sum;
    int a[10];
    bool vis[10];
    int ff;
};
asd q[N];
bool used[N];

int sco[10];int n,m,k;
bool cmp(asd z,asd x)
{
    if(z.sum>x.sum)
        return 1;
    else if(z.sum==x.sum)
    {
        int s1,s2;
        s1=s2=0;
        for(int i=1;i<=k;i++)
        {
            if(z.a[i]==sco[i])
                s1++;
            if(x.a[i]==sco[i])
                s2++;
        }
        if(s1>s2)
            return 1;
        else if(s1==s2)
        {
            if(z.name<x.name)
                return 1;
        }
    }
    return 0;
}

int main()
{

    memset(used,0,sizeof(used));
    cin>>n>>k>>m;
    for(int i=1;i<=k;i++)       //分數
        scanf("%d",&sco[i]);

    for(int i=1;i<=n;i++)       //初始化
    {
        q[i].name=i;            //名字
        for(int j=1;j<=5;j++)
            q[i].a[j]=0;        //分數都是0
        for(int j=1;j<=5;j++)
            q[i].vis[j]=0;      //提交
        q[i].sum=q[i].ff=0;     //sum分數,ff標記提交的那個
    }

    int mingzi,timu,fenshu;
    for(int i=0;i<m;i++)
    {
        scanf("%d%d%d",&mingzi,&timu,&fenshu);
        used[mingzi]=1;                 //有這個人

        if(fenshu!=-1)                  //交了
        {
            q[mingzi].ff=1;         //就會輸出的
            q[mingzi].vis[timu]=1;  //這道題目會輸出;
        }

        if(fenshu>q[mingzi].a[timu])   //更新分數
        {
            q[mingzi].a[timu]=fenshu;
        }
    }

    for(int i=1;i<=n;i++)
    {
        int x=q[i].name;
        if(used[x])
        {
            for(int j=1;j<=k;j++)
            {
                q[x].sum+=q[x].a[j];
            }
        }
    }

    sort(q+1,q+1+n,cmp);

   /* for(int i=1;i<=n;i++)
    {
        int x=q[i].name;
        if(used[x])
        {
            printf("%d %d\n",q[i].name,q[i].sum);
        }
    }*/

    int tep,hh,xx;
    hh=xx=1;
    for(int i=1;i<=n;i++)
    {
        int x=q[i].name;
        if(used[x]&&q[i].ff)
        {
            printf("1");
            printf(" %05d %d",x,q[i].sum);
            for(int j=1;j<=k;j++)
            {
                if(q[i].vis[j])
                    printf(" %d",q[i].a[j]);
                else
                    printf(" -");
            }
            puts("");
            xx++;
            tep=q[x].sum;
            used[x]=0;
            break;
        }
    }

    for(int i=1;i<=n;i++)
    {
        int x=q[i].name;
        if(!used[x]||!q[i].ff)
            continue;
        if(tep>q[i].sum)
        {
            hh=xx;
            tep=q[i].sum;

            printf("%d %05d %d",hh,x,tep);

            for(int j=1;j<=k;j++)
            {
                if(q[i].vis[j])
                    printf(" %d",q[i].a[j]);
                else
                    printf(" -");
            }
            puts("");
        }
        else if(tep==q[i].sum)
        {
            printf("%d %05d %d",hh,x,tep);
            for(int j=1;j<=k;j++)
            {
                if(q[i].vis[j])
                    printf(" %d",q[i].a[j]);
                else
                    printf(" -");
            }
            puts("");
            xx++;
        }
    }
    return 0;
}


/*
7 4 20
20 25 25 30
00002 2 12
00007 4 17
00005 1 19
00007 2 25
00005 1 20
00002 2 2
00005 1 15
00001 1 18
00004 3 25
00002 2 25
00005 3 22
00006 4 -1
00001 2 18
00002 1 20
00004 1 15
00002 4 18
00001 3 4
00001 4 2
00005 2 -1
00004 2 0
*/

相關推薦

PTA PAT Judge 模擬待續

The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to gen

Python自動化開發(一)待續

urn sts dha sel def open entos div 初始 1、創建項目    2、創建models from django.db import models # Create your models here. # 主機表 class Host(m

2018.02.12 noip模擬賽T2(待續)

代碼 8.0 scrip 復雜度 [] rip nbsp script 個數字 二兵的賭註 Description遊戲中,二兵要進入了一家奇怪的賭場。賭場中有n個莊家,每個莊家都可以猜大猜小,猜一次一元錢。每一次開彩前,你都可以到任意個莊家那裏下賭註。如果開彩結果是大,你就

[寫程序小技巧]不停更新待續……

表達式 pre b- 更新 這也 如果 防止 處的 程序 ①A&&B 首先判斷A的邏輯值,如果A的值為假,就可以判斷整個表達式的值為假,就不需要再判斷B的值。 這種用法非常有用,如果A是一個計算量較小的函數,B是一個計算量較大的函數,那麽首先判斷A對

spring基礎知識待續

沒有 代碼 ons maven model odi html www. 4.2 https://blog.csdn.net/slow_wakler/article/details/54895508 http://www.runoob.com/design-pattern

linux 基礎命令待續

保存 用戶 壓縮 使用情況 rmdir kill -9 移動 解壓縮 端口 1, cd 進入系統根目錄 cd / 進入當前用戶的主目錄 cd ~ 進入當前目錄的上一級目錄 cd .. 跳轉到指定目錄,從根目錄開始 cd /apps/ 2, pwd 查看當前工作目錄的完整路徑

對hibernate的簡單理解待續

一、hibernate的理解 百度百科:         hibernate是一個開源的ORM(物件關係對映)框架。ORM即object-relation mapping,它的作用就是在關係型資料庫和物件之間做了一個對映,從物件對映到關係,在

對struts2簡單理解待續

一、struts2的概念 來自百度百科:         Struts2是一個基於MVC設計模式的Web應用框架,它本質上相當於一個servlet,在MVC設計模式中,Struts2作為控制器(Controller)來建立模型與檢視的資料互動

Measuring Similarity between Clusters (Clusters 之間相似度的測量)待續

綜述 測量clusters(聚類)之間距離的方法一般可以分為四類, single linkage, complete linkage, average linkage , average groups linkage Single linkage 用兩個聚類中相鄰最近的點來做

你不知道的CSS常用屬性(不斷更新待續

顏色 HEX(16進位制色:color:#FFF000)。 RGB(紅綠藍:color:rgb(255,255,0)或color:rgb(100%,100%,20%))。 RGBA(紅綠藍透明度:color:rgba(255,255,0,0.5)。 HSL(

總結篇-其他(前端相關待續...)

1.IDE-sublime常用操作整理 (1)ctrl+shift+上下    上下移動游標所在行 (2)ctrl+f、ctrl+h        查詢、替換 (3)ctrl+p  @:符號跳轉;

總結篇-Javascript部分(絕對乾貨待續...)

0-0.常用的四種設計模式 1.工廠模式:解決多個相似的問題; 2.單例模式:只能被例項化一次; 3.沙箱模式:自執行函式,使用閉包把內部方法暴露出來,例: var fn=(function(){ function aFn(){}; return {

總結篇-CSS部分(絕對乾貨待續...)

1.自定義溢位顯示...(省略號) //情景一:單行顯示省略號 div{ width:100px; //多寬就要顯示省略號 overflow:hidden; //溢位隱藏 text-overflow:ellipsis; //文字溢位模式 whit

windows7下的docker的安裝及使用(持續更新待續每天一點點)

1.驗證電腦是否支援docker docker需要支援微軟的硬體虛擬化技術,且windows10只支援專業版(由於不用windows10請自行百度吧),windows10的安裝和windows7不同,windows7,8需要Toolbox,而windows10不用

基於Dubbo框架構建分散式服務待續

手機應用是以聊天室為基礎的,我們需要收集使用者的操作行為,然後計算聊天室中線上人數,並實時在手機應用端顯示人數,整個系統的架構如圖所示: 上圖中,主要包括了兩大主要流程:日誌收集並實時處理流程、呼叫讀取實時計算結果流程,我們使用基於Dubbo框架開發的服務來提供實時計算結果讀取聊天人數的功能。上圖中,實

ElasticSearch從入門到精通史上最全(持續更新待續每天一點點)

1.ElasticSearch的簡介 ElasticSearch:智慧搜尋,分散式的搜尋引擎 是ELK的一個組成,是一個產品,而且是非常完善的產品,ELK代表的是:E就是ElasticSearch,L就是Logstach,K就是kibana E:EalsticSea

jdbc14 及 jdbc16 共存所帶來的問題待續

在JAVA中JDK版本與JDBC版本的一致性十分重要,開發都們常常會忽略了這一點導致很多不必要的錯誤。昨天給客戶排查了一個關於EDB在JBoss中使用時關於這方面的問題,希望給大家一點啟發。 系統環境: Red Hat Enterpirse Linux 6 JBoss

滑動選單DrawerLayout詳解(實時更新待續...)

前言:目前所寫程式碼都是參照第一行程式碼所寫,但日後專案發現新的應用一定會實時更新。 一,在佈局中引入DrawerLayout activity_main.xml <?xml version="1.0" encoding="utf-8"?

[DIY]自制一個有漂亮外觀的90W 203H高頻焊臺 ---待續

//****************************前言 begin*********************************************// TB廢品價收了幾個CB機玩,多出來一個故障不明的壞機器,外殼很漂亮,一直想著可以把它改造成個儀器裝置

android面試題彙總待續

五. 網路儲存方式   44. 請介紹下ContentProvider是如何實現資料共享的。建立一個屬於你自己的Content provider或者將你的資料新增到一個已經存在的Contentprovider中,前提是有相同資料型別並且有寫入Content provider的許可權。   45. 如何