Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.3 kB
5
Indexable
Never
-------------------MAIN--------------------------

#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <stdio.h>

extern void init();
extern int add(int mId, int mGrade, char mGender[7], int mScore);
extern int remove(int mId);
extern int query(int mGradeCnt, int mGrade[], int mGenderCnt, char mGender[][7], int mScore);

/////////////////////////////////////////////////////////////////////////

#define CMD_INIT 100
#define CMD_ADD 200
#define CMD_REMOVE 300
#define CMD_QUERY 400

static bool run() {
	int q;
	scanf("%d", &q);

	int id, grade, score;
	char gender[7];
	int cmd, ans, ret;
	bool okay = false;

	for (int i = 0; i < q; ++i) {
		scanf("%d", &cmd);
		switch (cmd) {
			case CMD_INIT:
				init();
				okay = true;
				break;
			case CMD_ADD:
				scanf("%d %d %s %d %d", &id, &grade, gender, &score, &ans);
				ret = add(id, grade, gender, score);
				if (ans != ret)
					okay = false;
				break;
			case CMD_REMOVE:
				scanf("%d %d", &id, &ans);
				ret = remove(id);
				if (ans != ret)
					okay = false;
				break;
			case CMD_QUERY: {
				int gradeCnt, genderCnt;
				int gradeArr[3];
				char genderArr[2][7];
				scanf("%d", &gradeCnt);
				if (gradeCnt == 1) {
					scanf("%d %d", &gradeArr[0], &genderCnt);
				} else if (gradeCnt == 2) {
					scanf("%d %d %d", &gradeArr[0], &gradeArr[1], &genderCnt);
				} else {
					scanf("%d %d %d %d", &gradeArr[0], &gradeArr[1], &gradeArr[2], &genderCnt);
				}
				if (genderCnt == 1) {
					scanf("%s %d %d", genderArr[0], &score, &ans);
				} else {
					scanf("%s %s %d %d", genderArr[0], genderArr[1], &score, &ans);
				}
				ret = query(gradeCnt, gradeArr, genderCnt, genderArr, score);
				if (ans != ret)
					okay = false;
				break;
			}
			default:
				okay = false;
				break;
		}
	}
	return okay;
}

int main() {
	setbuf(stdout, NULL);
	freopen("input.txt", "r", stdin);

	int T, MARK;
	scanf("%d %d", &T, &MARK);

	for (int tc = 1; tc <= T; tc++) {
		int score = run() ? MARK : 0;
		printf("#%d %d\n", tc, score);
	}

	return 0;
}

-------------------USER--------------------------

#include <set>

using namespace std;

struct Student{
	int id;
	int grade;
	int gender;
	int score;
	Student(int mId, int mGrade, int mGender, int mScore){
		id = mId;
		grade = mGrade;
		gender = mGender;
		score = mScore;
	}
};

struct cmp{
	inline bool operator()(const Student& s1, const Student& s2) const{
		if(s1.score != s2.score)
			return s1.score < s2.score;
		return s1.id < s2.id;
	}
};

Student student[20001];
set<Student, cmp> mySet[3][2];
int index;


int convert(char str[])
{
	if (str[0] == 'm') return 1;
	return 0;
}

void init() {
	index = 0;
	for(int i = 0; i< 3; i++)
		for(int j = 0; j < 2; j++)
			mySet[i][j] = set<Student, cmp>();
	return;
}

int add(int mId, int mGrade, char mGender[7], int mScore) {

	int gender = convert(mGender);
	Student s1 = Student(mId, mGrade, gender, mScore);
	mySet[mGrade][mScore].insert(s1);

	auto it = --mySet[mGrade][mScore].end();
	auto s2 = *mySet[mGrade][mScore].find(*it);
	return s2.id;
}

int remove(int mId) {

	return 0;
}

int query(int mGradeCnt, int mGrade[], int mGenderCnt, char mGender[][7], int mScore) {
	return 0;
}