正文
增加 33 行删除 33 行
114 行未改动全部展开11511611711811912012112212351 行未改动175176177178179180181182183184291 行未改动全部展开4764774784794804814824834848 行未改动49349449549649749849950050114 行未改动51651751851952052152252352452552652752852953053153253353453553653712 行未改动5505515525535545555565575585595605615625635646 行未改动5715725735745755765775785795805815825835845855864 行未改动59159259359459559659759859931 行未改动631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663108 行未改动全部展开772773774775776777778779780119 行未改动全部展开90090190290390490590690790858 行未改动96796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007205 行未改动全部展开114 行未改动全部展开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: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;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'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.257223563b = (1 - f) * au1 = 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 = lsin_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**2a_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 # 转为 kmdef 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.","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.","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.","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.","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.","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.","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;time_last = time_now;}/*for(int i = 0;i < 128; ++i){119 行未改动全部展开#include <string>using namespace std;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];// 计算路径总节点数 kint 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 行未改动全部展开114 行未改动全部展开11511611711811912012112212351 行未改动175176177178179180181182183184291 行未改动全部展开4764774784794804814824834848 行未改动49349449549649749849950050114 行未改动51651751851952052152252352452552652752852953053153253353453553653712 行未改动5505515525535545555565575585595605615625635646 行未改动5715725735745755765775785795805815825835845855864 行未改动59159259359459559659759859931 行未改动631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663108 行未改动全部展开772773774775776777778779780119 行未改动全部展开90090190290390490590690790858 行未改动96796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007205 行未改动全部展开114 行未改动全部展开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: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;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'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.257223563b = (1 - f) * au1 = 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 = lsin_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**2a_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 # 转为 kmdef 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.","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.","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.","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.","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.","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.","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;time_last = time_now;}/*for(int i = 0;i < 128; ++i){119 行未改动全部展开#include <string>using namespace std;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];// 计算路径总节点数 kint 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 行未改动全部展开