[SOLVED]代码make时,出现has modification time 1.1e+07 s in the future

修改当前系统时间为当前电脑时间即可,执行命令  date -s '15:00:00 2018-01-25'
The team Test just finished an exciting JB/ICPC competition. They are eager to know their ranking, but the board has been closed. So they can only guess their ranking by observing the submissions of other teams. Now let’s briefly introduce the rules of ranking. Each team has two statistics: the number of solved problems and penalty time. All teams are ranked according to their numbers of solved problems. If the numbers of solved problems of two different teams are equal, then they are ranked according to the penalty time. Each time a team passes a problem, the number of solved problems +1, and the time (in minutes) elapsed from the beginning of the competition is added to their penalty time. If a team has multiple submissions, each of the failed submissions will result in a 20 added to their penalty time. At the time when the competition lasts for four hours, the board will stop updating. In other words, the board is "frozen". After that, you can only see the submission status of other teams (the number of attempts, the time of the last submission), but you cannot see whether those submissions are accepted or not. In addition, the competition lasts for five hours in total. In particular, all teams will not submit solutions to the problem after getting an "Accepted". If two teams have the same number of solved problems and penalty time, then they are ranked the same. Please help the team Test guess the highest and lowest rankings they can reach based on the current board. The input contains several test cases, and the first line contains a positive integer indicating the number of test cases, . For each test case, the first line is a positive integer indicating the number of other teams, where . Then for each team, the first line are two integers and , where indicating the number of solved problems and indicating the penalty time of this team. The second line contains an integer indicating the submissions of problems of this team after the board is frozen. Then following lines, each line contains two positive integers and indicating the time of the last submission and the submit times of a problem of this team. Finally there is one line contains two integers and indicating the number of solved problems and the penalty time of the team Test. For each test case, output a line containing two positive integers indicating the highest and lowest rankings of the team Test. 输入样例 1 1 1 30 1 250 2 1 20 输出样例 1 2
最新发布
12-19
我们来一步步解决这个 **ICPC 排名预测问题**,目标是: 给定当前“冻结排行榜”(frozen board)的状态,帮助队伍 `Test` 计算它在比赛结束后可能达到的 **最高排名** 和 **最低排名**。 --- ## 🧩 一、题目解析 ### ✅ 比赛规则回顾: - 比赛总长:5 小(300 分钟) - 排行榜在 **第 4 小结束冻结**(即 240 分钟) - 冻结后提交无法实看到是否 AC - 提交规则: - 每通过一道题: - 解决数量 +1 - 罚 += 从开始到 AC 的间(分钟) - 每道题只有第一次 AC 才计入,之后不再提交 - 每次失败提交(WA, TLE 等)会增加 20 分钟罚(仅当该题最终 AC 才会计入) > ❗注意:如果一个队在冻结后 AC 了一道题,那么他们的罚 = 冻结前失败次数 &times; 20 + 实际 AC 间(即使 >240) 但因为榜单已冻结,我们不知道他们有没有 AC。 --- ## 🎯 目标 给定: - 其他每个队的当前状态(解题数、罚、冻结后的提交记录) - Test 队自己的当前状态 求: - Test 队在所有可能情况下的 **最好排名(最高)** 和 **最差排名(最低)** --- ## 📌 输入说明 ``` T for each test case: n for i in range(n): solved_i penalty_i // 当前(冻结)的状态 k_i // 冻结后对此队的某题的提交数 for j in range(k_i): time_ij attempts_ij // 最后一次提交的间(<=300),以及累计提交次数(含冻结前?题目没说清楚) S_T P_T // Test 队当前的 solved 和 penalty ``` ⚠️ 注意:`attempts_ij` 是 **这道题总共的提交次数**,包括冻结前和冻结后的。 --- ## 🔍 关键点分析 对于每一个其他队伍,他们在冻结后可能: - 成功 AC 某些题(最多每道题一次 AC) - 增加罚(基于之前的错误提交) 但由于我们看不到结果,必须考虑两种极端情况: - **乐观情况**:尽可能多的队伍没有 AC 新题 → Test 排名靠前 - **悲观情况**:尽可能多的队伍 AC 了新题且不超越 Test → Test 排名靠后 但我们不能假设任意 AC —— 必须符合逻辑约束。 --- ## ✅ 解题策略 ### Step 1: 明确每支队伍能“新增”的解题情况 对每一支其他队伍 `i`,我们只知道他们冻结后对某些题有提交。但我们不知道这些题是不是已经 AC 过了。 但是题干中说: > “all teams will not submit solutions to the problem after getting an 'Accepted'” 所以:**只要有提交,说明这道题之前没有 AC!** 因此,这些提交有可能带来新的 AC。 而且,由于只能 AC 一次,所以每道题最多带来一次新 AC。 但输入格式是: ``` time_ij attempts_ij ``` 表示:在间 `time_ij`(≤300)做了最后一次提交,这是这道题的第 `attempts_ij` 次提交。 这意味着: - 如果这支队伍最终 AC 了这道题,则: - 新增 solved += 1 - 新增 penalty += (time_ij) + 20 * (attempts_ij - 1) 因为他们错了 `attempts_ij - 1` 次,最后一次 AC 在 `time_ij` 分钟。 但他们也可能没 AC(WA/TLE/CE...),那就 nothing changes. 所以我们需要枚举所有可能的 AC 组合?—— 不行,n 可达 100,组合爆炸。 但我们只关心 Test 的相对排名,可以用贪心或排序处理。 --- ## ✅ 正确做法:分别计算 best-case 和 worst-case ### 定义: - `test_solved`, `test_penalty`: Test 队当前值(不会再变,因为他们不会再提交) - 对于其他每个队伍,有两种可能状态: - 状态 A(未 AC):保持原 `solved`, `penalty` - 状态 B(AC 了):`solved+1`, `penalty + time + 20*(attempts-1)` > 注意:一支队伍可能有多道题在冻结后提交,但输入中每队只给一组 `(time, attempts)`?看样例: ``` 1 1 30 1 250 2 1 20 ``` → 1 支其他队伍,1 次冻结后提交,间为 250,共尝试 2 次。 → 所以每队最多考虑一道题?还是可以多行? 题目说:“following k lines”,k 是 submission count after freeze. 但每个 line 是 one problem’s last submission? Yes. So a team can have multiple problems with frozen submissions. So we must consider: this team may AC any subset of these problems? But no — because they would stop submitting if they got AC. But since they submitted after freeze, and haven’t been told result, it's possible that they AC any of them. However, **they cannot AC more than one per problem**, and **each line corresponds to a different problem**. And crucially: **they can only AC at most one new problem per problem attempted**, but since we don't know which ones pass, we assume worst/best. But to simplify: **assume each such submission is on a distinct problem, and each has potential to be ACed independently.** BUT: **a team can improve by at most the number of post-freeze submissions they made.** However, to maximize/minimize Test's rank, we need to decide for each other team whether they beat Test or not. But we can't try all subsets. Instead, use standard method: --- ## ✅ 标准解法(来自 ICPC practice) ### Step 1: 计算每个对手的最小可能 improvement 但实际上,我们只需考虑两种 scenario: --- ## 🟩 Best Rank (最高排名) —— 乐观情况 我们希望 **尽可能少的队伍排在 Test 前面** 怎么做? - 假设所有其他队伍都没有 AC 任何冻结后的题 → 他们的成绩不变 - 然后看有多少队伍本来就 ≥ Test 的成绩 - 但注意:Test 可能不能打败那些即使没提升也比它强的队伍 Wait: no — in best case, assume **no one improves** - Then calculate how many teams are strictly better than Test - Test's rank = number of teams better than it + 1 But also: some teams might tie with Test → same rank According to problem: “If two teams have the same number of solved problems and penalty time, then they are ranked the same.” So ranking rule: - Sort by solved ↓, penalty ↑ - Teams with identical (solved, penalty) share the same rank - Next team gets rank = previous rank + number of teams tied Example: - Team A: 3 100 - Team B: 3 100 → rank 1 - Team C: 3 90 → rank 3 So for best rank: - Assume no other team solves any new problem - Compute final standings - Count how many teams are strictly ahead of Test - Best rank = that count + 1 But wait: what if a team ties with Test? They have same rank! So best rank = 1 + number of teams that are strictly better than Test --- ## 🟥 Worst Rank (最低排名) —— 悲观情况 我们希望 **尽可能多的队伍排在 Test 前面或等于 Test** 怎么做? - 对每个其他队伍,判断它是否 **有可能** 变得比 Test 更好(或相等) - 如果能,我们就假设它真的做到了(在不矛盾的前提下) 具体来说: 对每个其他队伍 i: - 枚举它可能 AC 的子集 of its post-freeze submissions - 但它最多只能 AC 所有提交过的题目(每题至多一次) 但由于输入中每队有 k 个 submission records,每个 record 是一个 problem 的 last submit So max improvement: solve up to k new problems But usually k is small. But worst-case, we want to know: can team i finish with score > Test? Or even ≥ Test? We need to compute: **maximum possible solved and minimum penalty** it can achieve. Actually, penalty increases with time and wrong submits. To **beat Test**, a team wants: - More solved, or - Same solved but less penalty So for worst-case ranking: We assume that every team that **can possibly** end up with a better or equal result than Test **does so** Then Test's rank = number of teams that are >= Test in final outcome + 1? No Ranking: your rank = number of teams strictly better than you + 1 But if there are ties, you share rank. So worst-case: we want to maximize the number of teams that are **strictly better than or equal to Test**, but among those equal, only the first occurrence counts for blocking. Actually: > Final rank = 1 + (number of teams that are strictly better than Test in final state) Because even if 10 teams tie for first, next is 11th. But if Test ties with others, its rank is the first position of that group. So worst-case: minimize Test's standing by letting as many teams as possible become **strictly better** than Test. And also, let some teams tie with Test — but that doesn't change rank. Only teams strictly better push Test down. So: > Worst rank = 1 + max possible number of teams that can be strictly better than Test But also, if a team ties with Test, it doesn't affect rank. So strategy: For each other team: - Can it become strictly better than Test? - That is: either: - solved_final > test_solved, or - solved_final == test_solved and penalty_final < test_penalty Note: if it ties exactly, it doesn't hurt Test's rank So in worst-case, assume every team that **can possibly** become strictly better than Test **does become so** Then: > worst_rank = 1 + count_of_teams_that_can_be_strictly_better_than_Test But caution: a team may have multiple ways to improve; we only care if **at least one way** makes it strictly better. Also, Test's own score is fixed. --- ## ✅ 算法步骤总结 ```python best_case: others_final = [(s, p) for each other team] # no improvement count_better = 0 for s, p in others_final: if (s > test_solved) or (s == test_solved and p < test_penalty): count_better += 1 best_rank = count_better + 1 ``` ```python worst_case: count_better = 0 for each other team: current_s, current_p = given submissions = list of (time, attempts) # Try all subsets of these submissions that could be ACed # But since k <= ? and usually small, we can do bit mask best_possible_s = current_s + len(submissions) # But maybe not all can be solved # We want to know: can this team achieve: # (s_final > test_solved) OR (s_final == test_solved AND p_final < test_penalty) min_penalty_if_solve_k_extra = ? Actually, to minimize penalty, they should solve the early-time problems But penalty = sum over newly solved problems: time + 20*(attempts-1) So total new penalty = sum_{each newly solved problem} [time + 20*(attempts-1)] To check if can be strictly better than Test: Let max_new_solves = len(submissions) For r in range(max_new_solves + 1): # number of new problems solved total_s = current_s + r if total_s < test_solved: continue # Try to minimize added penalty add_penalty = sum of smallest r values of [time + 20*(attempts-1)] over submissions total_p = current_p + add_penalty if total_s > test_solved: can_be_better = True break elif total_s == test_solved and total_p < test_penalty: can_be_better = True break else: can_be_better = False if can_be_better: count_better += 1 worst_rank = count_better + 1 ``` But note: a team cannot solve a problem twice; each submission line is a separate problem. So yes, can solve any subset. --- ## ✅ 示例验证 输入样例: ``` 1 1 1 30 1 250 2 1 20 ``` 含义: - 1 个其他队伍 - 当前:1 题,罚 30 - 冻结后 1 次提交:最后提交间 250,共提交 2 次(即错 1 次) - Test 队:1 题,罚 20 ### Best Case: - 假设对方无提升 → 对方 (1,30), Test (1,20) - Test 更优(同题数,罚更少)→ 对方不比 Test 好 - 比 Test 好的队伍数 = 0 - best_rank = 1 ### Worst Case: - 对方可否变得比 Test 更好? - 新增 solved: 1 → 总 solved = 2 > Test's 1 → 是! - 即使新增罚 = 250 + 20*1 = 270 → 总罚 = 30 + 270 = 300 - 但 solved=2 > 1 → 严格更好 - 所以对方可以变得更好 - count_better = 1 - worst_rank = 1 + 1 = 2 输出:`1 2` ✅ 匹配 --- ## ✅ C++ 代码实现 ```cpp #include <iostream> #include <vector> #include <algorithm> #include <climits> using namespace std; struct Submission { int time; int attempts; }; int main() { int T; cin >> T; while (T--) { int n; cin >> n; vector<pair<int, int>> others; // (solved, penalty) vector<vector<Submission>> post_freeze(n); for (int i = 0; i < n; i++) { int s, p, k; cin >> s >> p >> k; others.push_back({s, p}); for (int j = 0; j < k; j++) { int tm, att; cin >> tm >> att; post_freeze[i].push_back({tm, att}); } } int test_solved, test_penalty; cin >> test_solved >> test_penalty; // Best case: no one improves int count_better_best = 0; for (auto &team : others) { int s = team.first; int p = team.second; if (s > test_solved || (s == test_solved && p < test_penalty)) { count_better_best++; } } int best_rank = count_better_best + 1; // Worst case: count how many can become strictly better than Test int count_better_worst = 0; for (int i = 0; i < n; i++) { int cur_s = others[i].first; int cur_p = others[i].second; auto &subs = post_freeze[i]; // Extract additional penalty for solving each problem vector<long long> extra_penalty; for (auto &sub : subs) { long long ep = sub.time + 20LL * (sub.attempts - 1); extra_penalty.push_back(ep); } sort(extra_penalty.begin(), extra_penalty.end()); // try to solve easiest first bool can_be_better = false; int total_new = extra_penalty.size(); // Try solving r new problems, r from 0 to total_new for (int r = 0; r <= total_new; r++) { long long add_p = 0; for (int j = 0; j < r; j++) { add_p += extra_penalty[j]; } int new_s = cur_s + r; long long new_p = cur_p + add_p; if (new_s > test_solved) { can_be_better = true; break; } else if (new_s == test_solved && new_p < test_penalty) { can_be_better = true; break; } } if (can_be_better) { count_better_worst++; } } int worst_rank = count_better_worst + 1; cout << best_rank << " " << worst_rank << endl; } return 0; } ``` --- ## ✅ 复杂度分析 - n ≤ 100 - Each team has k ≤ 10 submissions - Subset simulation via sorted prefix sum: O(k log k) - Total: O(n * k log k) → acceptable ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值