More actions
imported>Unknown No edit summary |
(Table transclusion repair v1) |
||
| Line 1: | Line 1: | ||
==== 소감 ==== | ==== 소감 ==== | ||
2005/05/03 Accepted 0:00.000 64 | |||
마지막 테스트 과정에서 버그가 있어서 애를 먹었다. | 마지막 테스트 과정에서 버그가 있어서 애를 먹었다. | ||
| Line 16: | Line 16: | ||
typedef struct{ | typedef struct{ | ||
int timeProblem | int timeProblem[NUMBER_PROBLEM]; | ||
int penalty; | int penalty; | ||
int numberSuccessProblem; | int numberSuccessProblem; | ||
| Line 36: | Line 36: | ||
cin.get(); | cin.get(); | ||
ContestTeam team | ContestTeam team[NUMBER_TEAM]; | ||
bool isSumit | bool isSumit[NUMBER_TEAM]; | ||
int rankTeam | int rankTeam[NUMBER_TEAM]; | ||
int numberSumitTeam; | int numberSumitTeam; | ||
int i; | int i; | ||
| Line 65: | Line 65: | ||
{ | { | ||
for (int j = 1; j < NUMBER_PROBLEM; j++) | for (int j = 1; j < NUMBER_PROBLEM; j++) | ||
team | team[i].timeProblem[j] = 0; | ||
team | team[i].penalty = 0; | ||
team | team[i].numberSuccessProblem = 0; | ||
} | } | ||
} | } | ||
| Line 74: | Line 74: | ||
{ | { | ||
for (int i = 1; i < NUMBER_TEAM; i++) | for (int i = 1; i < NUMBER_TEAM; i++) | ||
isSumit | isSumit[i] = 0; | ||
} | } | ||
| Line 82: | Line 82: | ||
for (int i = 1; i < NUMBER_TEAM; i++) | for (int i = 1; i < NUMBER_TEAM; i++) | ||
{ | { | ||
if (isSumit | if (isSumit[i] == true) | ||
rankTeam | rankTeam[count++] = i; | ||
} | } | ||
return count; | return count; | ||
| Line 100: | Line 100: | ||
} | } | ||
cin >> numTeam >> numProblem >> time >> L; | cin >> numTeam >> numProblem >> time >> L; | ||
isSumit | isSumit[numTeam] = true; | ||
switch (L) | switch (L) | ||
{ | { | ||
case 'C': | case 'C': | ||
if (team | if (team[numTeam].timeProblem[numProblem] == -1) | ||
break; | break; | ||
team | team[numTeam].penalty += team[numTeam].timeProblem[numProblem] + time; | ||
team | team[numTeam].numberSuccessProblem++; | ||
team | team[numTeam].timeProblem[numProblem] = -1; | ||
break; | break; | ||
case 'I': | case 'I': | ||
if (team | if (team[numTeam].timeProblem[numProblem] == -1) | ||
break; | break; | ||
team | team[numTeam].timeProblem[numProblem] += TIME_PENALTY; | ||
break; | break; | ||
} | } | ||
| Line 129: | Line 129: | ||
for (int j = i + 1; j < numberSumitTeam; j++) | for (int j = i + 1; j < numberSumitTeam; j++) | ||
{ | { | ||
if (team | if (team[rankTeam[top]].numberSuccessProblem < team[rankTeam[j]].numberSuccessProblem) | ||
SWAP(rankTeam | SWAP(rankTeam[top], rankTeam[j], temp); | ||
else if (team | else if (team[rankTeam[top]].numberSuccessProblem == team[rankTeam[j]].numberSuccessProblem) | ||
{ | { | ||
if (team | if (team[rankTeam[top]].penalty > team[rankTeam[j]].penalty) | ||
SWAP(rankTeam | SWAP(rankTeam[top], rankTeam[j], temp); | ||
} | } | ||
| Line 144: | Line 144: | ||
{ | { | ||
for (int i = 1; i < numberSumitTeam; i++) | for (int i = 1; i < numberSumitTeam; i++) | ||
cout << rankTeam | cout << rankTeam[i] << " " << team[rankTeam[i]].numberSuccessProblem << " " << team[rankTeam[i]].penalty << endl; | ||
} | } | ||
---- | ---- | ||
[[ContestScoreBoard]] [[AOI]] | [[ContestScoreBoard]] [[AOI]] | ||
Latest revision as of 12:46, 27 March 2026
소감
2005/05/03 Accepted 0:00.000 64
마지막 테스트 과정에서 버그가 있어서 애를 먹었다.
코드
// no10258 - Contest Score Board
#include <iostream>
using namespace std;
#define SWAP(x, y, t) ((t) = (x), (x) = (y), (y) = (t))
const int NUMBER_TEAM = 101;
const int NUMBER_PROBLEM = 10;
const int TIME_PENALTY = 20;
typedef struct{
int timeProblem[NUMBER_PROBLEM];
int penalty;
int numberSuccessProblem;
}ContestTeam;
void inputInfoContest(ContestTeam * team, bool * isSumit);
void initialize(ContestTeam * team, bool * isSumit);
void initializeTeam(ContestTeam * team);
void initializeIsSumit(bool * isSumit);
int settingRank(bool * isSumit, int * rankTeam);
void concludeRank(ContestTeam * team, int * rankTeam, int numberSumitTeam);
void printRank(ContestTeam * team, int * rankTeam, int numberSumitTeam);
int main()
{
int numberCase;
cin >> numberCase;
cin.get();
cin.get();
ContestTeam team[NUMBER_TEAM];
bool isSumit[NUMBER_TEAM];
int rankTeam[NUMBER_TEAM];
int numberSumitTeam;
int i;
for (i = 0; i < numberCase; i++)
{
initialize(team, isSumit);
inputInfoContest(team, isSumit);
numberSumitTeam = settingRank(isSumit, rankTeam);
concludeRank(team, rankTeam, numberSumitTeam);
printRank(team, rankTeam, numberSumitTeam);
if (i != numberCase - 1)
cout << endl;
}
return 0;
}
void initialize(ContestTeam * team, bool * isSumit)
{
initializeTeam(team);
initializeIsSumit(isSumit);
}
void initializeTeam(ContestTeam * team)
{
for (int i = 1; i < NUMBER_TEAM; i++)
{
for (int j = 1; j < NUMBER_PROBLEM; j++)
team[i].timeProblem[j] = 0;
team[i].penalty = 0;
team[i].numberSuccessProblem = 0;
}
}
void initializeIsSumit(bool * isSumit)
{
for (int i = 1; i < NUMBER_TEAM; i++)
isSumit[i] = 0;
}
int settingRank(bool * isSumit, int * rankTeam)
{
int count = 1;
for (int i = 1; i < NUMBER_TEAM; i++)
{
if (isSumit[i] == true)
rankTeam[count++] = i;
}
return count;
}
void inputInfoContest(ContestTeam * team, bool * isSumit)
{
int numTeam, numProblem, time;
char L;
while (cin.peek() != EOF)
{
if (cin.peek() == '\n')
{
cin.get();
break;
}
cin >> numTeam >> numProblem >> time >> L;
isSumit[numTeam] = true;
switch (L)
{
case 'C':
if (team[numTeam].timeProblem[numProblem] == -1)
break;
team[numTeam].penalty += team[numTeam].timeProblem[numProblem] + time;
team[numTeam].numberSuccessProblem++;
team[numTeam].timeProblem[numProblem] = -1;
break;
case 'I':
if (team[numTeam].timeProblem[numProblem] == -1)
break;
team[numTeam].timeProblem[numProblem] += TIME_PENALTY;
break;
}
cin.get();
}
}
void concludeRank(ContestTeam * team, int * rankTeam, int numberSumitTeam)
{
int top;
int temp;
for (int i = 1; i < numberSumitTeam; i++)
{
top = i;
for (int j = i + 1; j < numberSumitTeam; j++)
{
if (team[rankTeam[top]].numberSuccessProblem < team[rankTeam[j]].numberSuccessProblem)
SWAP(rankTeam[top], rankTeam[j], temp);
else if (team[rankTeam[top]].numberSuccessProblem == team[rankTeam[j]].numberSuccessProblem)
{
if (team[rankTeam[top]].penalty > team[rankTeam[j]].penalty)
SWAP(rankTeam[top], rankTeam[j], temp);
}
}
}
}
void printRank(ContestTeam * team, int * rankTeam, int numberSumitTeam)
{
for (int i = 1; i < numberSumitTeam; i++)
cout << rankTeam[i] << " " << team[rankTeam[i]].numberSuccessProblem << " " << team[rankTeam[i]].penalty << endl;
}