版本比较
MAFC 2026 题解
正文
增加 94 行删除 36 行
12234569 行未改动16171819202021222324252627282930313233343536373839404122424344454647484950515253545556575859606162636465666768697071727374757677787980818283848529 行未改动1151161171186111912012112212351 行未改动175176177178121122179180181182183184291 行未改动全部展开4764774784794224804814824834848 行未改动49349449549643949749849950050114 行未改动51651751851946252052152252352446752552652752852947253053153247553353453553653712 行未改动5505515525534965545555565575585595025605615625635646 行未改动5715725735745175755765775785795805815245825835845855864 行未改动59159259359453759559659759859931 行未改动631632633634577635636579637638639640641642643644587588645646647648649592650651652595653654655656657600601658659660661662663108 行未改动全部展开772773774775718776777778779780119 行未改动全部展开90090190290384690490590690790858 行未改动96796896997091397197297397497597697792097897998098198292598398498598698793098898999099193499299393699499599693999799899994210001001100294510031004100510061007205 行未改动全部展开# MAFC 2026 题解# [比赛评价链接](https://mafc2026.murasame.site/)# [比赛链接](https://www.luogu.com.cn/contest/317826) | [评价链接](https://mafc2026.murasame.site/)
首先感谢大家的参赛和热烈支持!以下是一些本次比赛的统计信息:
- 报名人数:$\color{red}{\textbf{3,192}}$(同比增长 $\color{red}{\textbf{894.39\%}}$)9 行未改动比赛及题目评价 & 看法通道:<https://mafc2026.murasame.site>。
领奖:**洛谷 [私信](/chat?uid=682739)** 你的 QQ 号,**QQ 加 3871125508 好友** 备注洛谷号,提供付款方式(vx/zfb,收款码)。
一些统计图::::info[统计表格]| 题目 | 平均数 | 中位数 | 众数 | 方差 | 得分人数 || :---: | :---: | :---: | :---: | :---: | :---: || **A** | 43.45 | 30.0 | 15 | 2408.05 | 656 || **B** | 150.00 | 150.0 | 150 | 0.00 | 14 || **C** | 127.46 | 81.0 | 81 | 7471.79 | 39 || **D** | 200.00 | 200.0 | 200 | 0.00 | 14 || **E** | 44.39 | 42.0 | 42 | 126.74 | 336 || **F** | 66.77 | 75.0 | 30 | 1754.11 | 31 || **G** | 150.00 | 150.0 | 150 | 0.00 | 4 || **H** | 50.00 | 50.0 | 50 | 0.00 | 695 || **I** | 248.18 | 245.0 | 200 | 13934.25 | 195 || **J** | 200.00 | 200.0 | 200 | 0.00 | 9 || **K** | 150.00 | 150.0 | 150 | 0.00 | 12 || **L** | 300.00 | 300.0 | 300 | 0.00 | 4 || **M** | 100.00 | 100.0 | 100 | 0.00 | 63 || **N** | 95.00 | 100.0 | 100 | 225.00 | 40 || **O** | 100.00 | 100.0 | 100 | 0.00 | 139 || **P** | 100.00 | 100.0 | 100 | 0.00 | 31 || **Q** | 100.00 | 100.0 | 100 | 0.00 | 10 |:::
[TBD]:::info[统计图]

















:::
## A
- 满分:- 有分平均分:29 行未改动 summary_text = await page.locator(".resultsNumbers").inner_text() match = re.search(r"([\d,]+)\s+to", summary_text) if not match: match = re.search(r"([\d,]+)", summary_text) if not match: if not match: return None, [] start_rank = int(match.group(1).replace(",", "")) hws = await page.locator(".hw").all_inner_texts() return start_rank, hws51 行未改动 std::string word; int rank;};bool CompareWords(const std::string& a, const std::string& b) { if (a.empty() && !b.empty()) return false; if (!a.empty() && b.empty()) return true; if (a.empty() && !b.empty()) return false; if (!a.empty() && b.empty()) return true; return a < b;}bool CompareAnchor(const Anchor& anchor, const std::string& target) { return CompareWords(anchor.word, target);291 行未改动全部展开
# --- 配置区域 ---GOOGLE_MAPS_API_KEY = "<REDACTED FOR PRIVACY>"# 模式选择: 'wgs84' (精确, 推荐) 或 'spherical' (简单球体)MODE = 'wgs84' MODE = 'wgs84'
def decode_location(hex_str): """hex -> base64 -> string""" try:8 行未改动 print(f"fetching coordinates for: {name}")
safe_name = urllib.parse.quote(name) url = f"https://maps.googleapis.com/maps/api/geocode/json?address={safe_name}&key={api_key}"
try: with urllib.request.urlopen(url) as response: data = json.loads(response.read().decode()) if data['status'] == 'OK':14 行未改动
def dist_wgs84(lat1, lon1, lat2, lon2): """wgs-84 椭球模型 (vincenty's formulae)""" if (lat1, lon1) == (lat2, lon2): return 0.0
# wgs-84 参数 a = 6378137.0 # 赤道半径 (m) f = 1 / 298.257223563 b = (1 - f) * a
u1 = math.atan((1 - f) * math.tan(math.radians(lat1))) u2 = math.atan((1 - f) * math.tan(math.radians(lat2))) l = math.radians(lon2 - lon1) lambda_lon = l
sin_u1, cos_u1 = math.sin(u1), math.cos(u1) sin_u2, cos_u2 = math.sin(u2), math.cos(u2)
for _ in range(100): sin_lambda, cos_lambda = math.sin(lambda_lon), math.cos(lambda_lon) sin_sigma = math.sqrt((cos_u2 * sin_lambda)**2 + (cos_u1 * sin_u2 - sin_u1 * cos_u2 * cos_lambda)**2) if sin_sigma == 0: return 0.012 行未改动 u2_sq = cos2_alpha * (a**2 - b**2) / b**2 a_param = 1 + u2_sq / 16384 * (4096 + u2_sq * (-768 + u2_sq * (320 - 175 * u2_sq))) b_param = u2_sq / 1024 * (256 + u2_sq * (-128 + u2_sq * (74 - 47 * u2_sq))) delta_sigma = b_param * sin_sigma * (cos2_sigma_m + b_param / 4 * (cos_sigma * (-1 + 2 * cos2_sigma_m**2) - b_param / 6 * cos2_sigma_m * (-3 + 4 * sin_sigma**2) * (-3 + 4 * cos2_sigma_m**2)))
return b * a_param * (sigma - delta_sigma) / 1000.0 # 转为 km
def main(): # 简单的缓存避免重复查询 cache = {}
try: with open('test.in', 'r') as f: lines = f.read().splitlines() except:6 行未改动
for i in range(1, q + 1): u_hex, v_hex = lines[i].split() u_name, v_name = decode_location(u_hex), decode_location(v_hex)
coords = [] for name in [u_name, v_name]: if name not in cache: cache[name] = get_coordinates(name, GOOGLE_MAPS_API_KEY) time.sleep(0.02) # 防止请求过快 coords.append(cache[name])
if coords[0] and coords[1]: if MODE == 'wgs84': d = dist_wgs84(*coords[0], *coords[1]) other_d = dist_spherical(*coords[0], *coords[1])4 行未改动 other_results.append(f"{other_d:.4f}") else: results.append("0.0000") other_results.append("0.0000")
if i % 10 == 0: print(f"progress: {i}/{q}")
with open('1.out', 'w') as f: f.write('\n'.join(results) + '\n')31 行未改动char keys[16] = "furryCTF";char fakekey[] = "\xde\xad\xbe\xef\xde\xad\xbe\xef\xde\xad\xbe\xef\xde\xad\xbe\xef\xde\xad\xbe\xef\xde\xad\xbe\xef\xde\xad\xbe\xef\xde\xad\xbe\xef\xde\xad\xbe\xef";unsigned char cipher[128+16] = "\x21\x71\xd8\xed\xdd\xa9\xcb\x02\xfb\x3e\x77\xdf\x96\x6d\x6d\x29\x69\xcf\xdc\xc1\xea\xbe\x23\xaa\x1d\xe4\x25\xd4\x9d\x3a\x8a\x50\xca\xd6\x86\x48\x21\xfb\xd5\x75\x44\x49\x63\x1b\x30\xb8\x18\x39\x22\xb2\x43\xc8\x82\x06\xdc\x1d\x88\xbf\x1a\xb8\x0c\xfb\x54\xc9\x57\x7a\xb3\xdd\x94\x70\x06\xad\x41\x8f\x13\x7b\x66\x31\x90\xf7\xec\xdc\xb7\xe8\xc4\x60\x3c\x69\xbd\xd8\x8e\x9b\xab\xa0\x50\x07\xcd\x40\x7c\xfe\x30\xf2\xca\x45\xe2\x53\x7d\x19\xd8\x16\x79\xbd\x47\xd3\x93\x33\xcd\xcb\xd4\xca\xde\x38\xb5\xc5\x36\xff\xa3\x87";char *mystr[] = { "The Wired is the upper directory of the real world.", "The Wired is the upper directory of the real world.", "I am merely a container. What you see is an illusion created by your own mind.", "We did not choose each other; we each chose ourselves.", "We did not choose each other; we each chose ourselves.", "Why? Because we are strangers.", "People only have substance in the memories of others.", "Everywhere you go, everyone is connected.", "There is no need for a physical body. It is redundant.", "God exists here... in the Wired.", "I exist only to relay commands, never touching reality.", "Reality is but a failed experiment.", "Even if this world is false, it is the only one.", "Pain in reality is the most effective way to change a heart.", "Even if this world is false, it is the only one.", "Pain in reality is the most effective way to change a heart.", "I am always in an experiment, now and forever.", "Memories are just records. Without records, nothing ever happened.", "Present day... present time... Ha ha ha ha!", "Why die? Because life and death are the same.", "Why die? Because life and death are the same.", "Am I real? Or am I a program written by someone?", "The collective consciousness projects physical phenomena.", "The self is defined by connections, not by flesh.", "The self is defined by connections, not by flesh.", "To observe is to create. To be observed is to be bound.", "In the Wired, I am everywhere and nowhere.", "Your fears will turn to whispers in your ear.", "The boundary between sanity and madness is yours to draw.", "Without the Wired, would you still be you?", "Loneliness is the shadow of connection.", "Without the Wired, would you still be you?", "Loneliness is the shadow of connection.", "I am falling, I am fading, I am drowning... Help me to breathe.", /* e.t.c */ "Data flows like blood in the veins of the Wired.", "To delete a memory is to erase a universe.",108 行未改动全部展开 } unsigned long int next_key = *(unsigned long int *)(fakekey+3) + time_now - time_BASE; srand(next_key); cipher[i % 128] ^= (unsigned char) rand() % 256; cipher[i % 17] ^= (unsigned char) rand() % 256; cipher[i % 17] ^= (unsigned char) rand() % 256; time_last = time_now; } /* for(int i = 0;i < 128; ++i){119 行未改动全部展开#include <string>
using namespace std;
const int MAX_NODES = 200005; const int MAX_NODES = 200005;const long long MOD = 1000000007;
int depth[MAX_NODES];int up[MAX_NODES][20];58 行未改动 if (type == "ADD") { int p; long long w; cin >> p >> w;
node_cnt++; int u = node_cnt; depth[u] = depth[p] + 1; weight[u] = w; xor_to_root[u] = xor_to_root[p] ^ w; up[u][0] = p;
// 维护倍增祖先 for (int j = 1; j < 20; j++) { up[u][j] = up[up[u][j - 1]][j - 1]; } } } else if (type == "DEL") { int x; cin >> x; // 障眼法,完全忽略! } } else if (type == "QUERY") { int u, v; cin >> u >> v;
int lca = get_lca(u, v);
// 真实路径的异或和(由于lca被异或了两次抵消了,需要再补上一次) long long path_xor = xor_to_root[u] ^ xor_to_root[v] ^ weight[lca];
// 计算路径总节点数 k int path_len = depth[u] + depth[v] - 2 * depth[lca] + 1;
// 加上因 f(i)=3 而额外产生的异或操作,最后取模 long long final_ans = (path_xor ^ magic_xor[path_len]) % MOD;
cout << final_ans << "\n"; } } return 0;205 行未改动全部展开