結果
| 問題 |
No.449 ゆきこーだーの雨と雪 (4)
|
| ユーザー |
くれちー
|
| 提出日時 | 2016-11-19 19:32:58 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 3,355 bytes |
| コンパイル時間 | 930 ms |
| コンパイル使用メモリ | 23,296 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 10:25:13 |
| 合計ジャッジ時間 | 10,302 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 RE * 34 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:95:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
95 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
main.c:101:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
101 | scanf("%d", &l);
| ^~~~~~~~~~~~~~~
main.c:106:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
106 | scanf("%d", &t);
| ^~~~~~~~~~~~~~~
main.c:114:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
114 | scanf("%s %c", name[i], &p[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct {
int Level;
int Solve;
} Problem;
Problem *Problem_New(int level) {
Problem *p;
p = (Problem *)malloc(sizeof(Problem));
p->Level = level;
p->Solve = 0;
return p;
}
int Problem_GetId(char name) {
return name - 'A';
}
typedef struct {
char *Name;
char ProblemName;
} Submit;
Submit *Submit_New(char *name, char problemName) {
Submit *s;
s = (Submit *)malloc(sizeof(Submit));
s->Name = name;
s->ProblemName = problemName;
return s;
}
typedef struct {
char *Name;
int Score[26];
int ScoreSum;
int LastSubmit;
} Participant;
Participant *Participant_New_1(char *name) {
Participant *p;
p = (Participant *)malloc(sizeof(Participant));
p->Name = name;
return p;
}
Participant *Participant_New_2(char *name, int problemNum, int lastSubmit) {
Participant *p;
p = (Participant *)malloc(sizeof(Participant));
p->Name = name;
int i;
for (i = 0; i < problemNum; i++) p->Score[i] = 0;
p->ScoreSum = 0;
p->LastSubmit = lastSubmit;
return p;
}
int Participant_Equals(Participant *p1, Participant *p2) {
return strcmp(p1->Name, p2->Name) == 0 ? 1 : 0;
}
int Participant_CompareTo(const void *p1, const void *p2) {
if (((Participant *)p1)->ScoreSum == ((Participant *)p2)->ScoreSum)
return ((Participant *)p1)->LastSubmit - ((Participant *)p2)->LastSubmit;
else
return ((Participant *)p2)->ScoreSum - ((Participant *)p1)->ScoreSum;
}
void Participant_Solve(Participant *p, int no, int level, int rank) {
p->Score[no] = 50 * level + (500 * level / (8 + 2 * rank));
p->ScoreSum += p->Score[no];
}
int Participant_List_Contains(Participant *p1, int size, Participant *p2) {
int i;
for (i = 0; i < size; i++) {
if (Participant_Equals(&p1[i], p2)) return 1;
}
return 0;
}
int Participant_List_IndexOf(Participant *p1, int size, Participant *p2) {
int i;
for (i = 0; i < size; i++) {
if (Participant_Equals(&p1[i], p2)) return i;
}
return -1;
}
int main() {
int n;
scanf("%d", &n);
Problem problemList[26];
int i, j;
for (i = 0; i < n; i++) {
int l;
scanf("%d", &l);
problemList[i] = *Problem_New(l);
}
int t;
scanf("%d", &t);
Submit submitList[4000];
int cntParticipant = 0;
Participant participantList[4000];
int cntSubmit = 0;
for (i = 0; i < t; i++) {
char name[4000][17], p[4000];
scanf("%s %c", name[i], &p[i]);
if (p[i] == '?') {
qsort(participantList, cntParticipant,
sizeof(Participant), Participant_CompareTo);
printf("%d\n", Participant_List_IndexOf(
participantList, cntParticipant, Participant_New_1(name[i])) + 1);
}
else {
submitList[i] = *Submit_New(name[i], p[i]);
if (!Participant_List_Contains(participantList, cntParticipant,
Participant_New_1(submitList[i].Name))) {
participantList[cntParticipant] = *Participant_New_2(name[i], n, i);
cntParticipant++;
}
int tmpProblemNo =
Problem_GetId(submitList[i].ProblemName);
int tmpParticipantNo =
Participant_List_IndexOf(participantList, cntParticipant,
Participant_New_1(submitList[i].Name));
problemList[tmpProblemNo].Solve++;
Participant_Solve(
&participantList[tmpParticipantNo],
tmpProblemNo,
problemList[tmpProblemNo].Level,
problemList[tmpProblemNo].Solve
);
participantList[tmpParticipantNo].LastSubmit = i;
cntSubmit++;
}
}
return 0;
}
くれちー