QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#497464#4912. WereYouLastbykem100 ✓5447ms5004kbC++201.1kb2024-07-29 09:19:172024-07-29 09:19:18

Judging History

你现在查看的是最新测评结果

  • [2024-07-29 09:19:18]
  • 评测
  • 测评结果:100
  • 用时:5447ms
  • 内存:5004kb
  • [2024-07-29 09:19:17]
  • 提交

answer

bool query(int);
void modify(int, bool);

const int kT[3][42][2] = {
	{{}, {2, 13}, {3, 8}, {4, 6}, {5}, {}, {0, 7}, {}, {9, 11}, {0, 10}, {}, {12}, {}, {14, 19}, {15, 17}, {0, 16}, {}, {18}, {}, {20, 22}, {21}, {}, {0, 23}, {}},
	{{}, {2, 17}, {3, 10}, {4, 8}, {5}, {6, 7}, {}, {}, {0, 9}, {}, {11}, {12, 14}, {0, 13}, {}, {15, 16}, {}, {}, {18, 25}, {19}, {20, 22}, {0, 21}, {}, {23, 24}, {}, {}, {26, 30}, {27}, {28, 29}, {}, {}, {0, 31}, {}},
	{{}, {2, 23}, {3, 13}, {4, 8}, {5, 7}, {6}, {}, {}, {9, 12}, {10, 11}, {}, {}, {}, {14, 21}, {15, 18}, {16, 17}, {}, {}, {19, 20}, {}, {}, {22}, {}, {24, 33}, {25, 29}, {26, 28}, {27}, {}, {}, {30}, {31, 32}, {}, {}, {34, 38}, {35}, {36, 37}, {}, {}, {39, 41}, {40}, {}, {}}
};

bool count(int o, int x) {
	if (!x) {
		return 1;
	}
	if (query(x)) {
		modify(x, 0);
		return count(o, kT[o][x][1]);
	}
	modify(x, count(o, kT[o][x][0]));
	return 0;
}
bool WereYouLast(int n, int m) {
	if (n == (1 << 10)) {
		int i = 1;
		for (; i <= 10 && query(i); modify(i++, 0)) {
		}
		if (i == 11) {
			return 1;
		}
		modify(i, 1);
		return 0;
	}
	return count(n == (1 << 26) ? 2 : n == (1 << 20), 1);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 3756kb

input:

1024 10

output:

12345876 10 10

result:

ok Correct Answer.
C1 = 10.
C2 = 10.

Subtask #2:

score: 20
Accepted

Test #2:

score: 20
Accepted
time: 5ms
memory: 4988kb

input:

65536 100000

output:

12345876 5 5

result:

ok Correct Answer.
C1 = 5.
C2 = 5.

Subtask #3:

score: 30
Accepted

Test #3:

score: 30
Accepted
time: 87ms
memory: 5004kb

input:

1048576 100000

output:

12345876 6 6

result:

ok Correct Answer.
C1 = 6.
C2 = 6.

Subtask #4:

score: 40
Accepted

Test #4:

score: 40
Accepted
time: 5447ms
memory: 4972kb

input:

67108864 100000

output:

12345876 6 6

result:

ok Correct Answer.
C1 = 6.
C2 = 6.