結果

問題 No.449 ゆきこーだーの雨と雪 (4)
ユーザー くれちーくれちー
提出日時 2016-11-19 19:45:56
言語 C90
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 3,366 bytes
コンパイル時間 505 ms
コンパイル使用メモリ 23,680 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-09-22 10:26:05
合計ジャッジ時間 28,865 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 5 ms
6,940 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 4 ms
6,940 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 4 ms
6,940 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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++) {
		static char name[100000][17], p[100000];
		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;
}
0