知乎version: https://zhuanlan.zhihu.com/p/651696440

A. 如图

图里有个七夕,所以输出“七夕”即可。小沙喜欢搞抽象导致的,我是没看出来。

#include<bits/stdc++.h>

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	std::cout << "七夕";

	return 0;
}

alt

B. 嘤嘤的构造

注意,是 子矩阵的和的极差最小,不是 子矩阵内的极差最小。小沙说最多五行,多一行都有问题。

alt

#include<bits/stdc++.h>

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int n;
	std::cin >> n;

	int x = 1, y = n * n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			std::cout << ((i + j & 1) ? (x++) : (y--)) << " \n"[j == n];
		}
	}

	return 0;
}

C. 小红的环形数组

大力算一算。

#include<bits/stdc++.h>

using i64 = long long;
constexpr i64 mod = 1e9 + 7;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int n;
	std::cin >> n;

	i64 x = 0, y = 0;
	for (int i = 0; i < n; i++) {
		int a;
		std::cin >> a;
		(x += a) %= mod;
		(y += std::min(i, n - i)) %= mod;
	}
	std::cout << x * y % mod;

	return 0;
}

D. 小红的完全k叉树

正经算法题就不写题解了哈。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

inline ll read() {
    char ch;
    ll x = 0;
    bool f = true;
    for (ch = getchar(); !isdigit(ch); ch = getchar())
        if (ch == '-')
            f ^= f;
    for (; isdigit(ch); ch = getchar())
        x = (x << 3) + (x << 1) + ch - 48;
    return f ? x : -x;
}

template <int T>
struct ModInt {
    const static int MD = T;
    int x;
    ModInt(ll x = 0)
        : x(x % MD) {}
    int get() { return x; }
    ModInt operator+(const ModInt& that) const {
        int x0 = x + that.x;
        return ModInt(x0 < MD ? x0 : x0 - MD);
    }
    ModInt operator-(const ModInt& that) const {
        int x0 = x - that.x;
        return ModInt(x0 < MD ? x0 + MD : x0);
    }
    ModInt operator*(const ModInt& that) const {
        return ModInt((long long)x * that.x % MD);
    }
    ModInt operator/(const ModInt& that) const {
        return *this * that.inverse();
    }
    void operator+=(const ModInt& that) {
        x += that.x;
        if (x >= MD)
            x -= MD;
    }
    void operator-=(const ModInt& that) {
        x -= that.x;
        if (x < 0)
            x += MD;
    }
    void operator*=(const ModInt& that) { x = (long long)x * that.x % MD; }
    void operator/=(const ModInt& that) { *this = *this / that; }
    ModInt inverse() const {
        int a = x, b = MD, u = 1, v = 0;
        while (b) {
            int t = a / b;
            a -= t * b;
            std::swap(a, b);
            u -= t * v;
            std::swap(u, v);
        }
        if (u < 0)
            u += MD;
        return u;
    }
    friend ostream& operator<<(ostream& os, ModInt x) {
        os << x.get();
        return os;
    }
};
const int mod = 1e9 + 7;
typedef ModInt<mod> mint;

mint ksm(int n, mint m) {
    mint ans = 1;
    for (; n; n >>= 1, m *= m)
        if (n & 1)
            ans *= m;
    return ans;
}

int main() {
    ll n = read(), m = read(), k = read();
    mint ans = 0;
    for (int i = min(m,n); i >= (m + 1) / 2; i--) {
        mint res = ((ksm(n, k) - 1) / (k - 1)) - ((ksm(i, k) - 1) / (k - 1));
        if (i != m) {
            res *= k - 1;
            res *= ksm(m - i - 1, k);
        }
        if (i * 2 == m) {
            res /= 2;
        }
        ans += res;
    }
    cout << ans << "\n";
    return 0;
}

E. 七夕自动姬

七夕娱乐赛当然要胆子大一点直接输出 QwQ 辣。

然后下面是可能正解的玩意,嘴笨说不明白了:

记1:数组 每个位置的七种石头的前缀和为 。当 时,。 记2:从第 人开始施法,直到第 人结束,中途不会出现七惜石不够的情况的区间为合法区间(不一定是闲暇区间),即 可知:如果一个区间 是闲暇区间,则必然满足 ,反之则不一定。 设 ,即,所有以 为右边界的合法区间的左边界位置的集合 若 ,显然增加一颗石头不会影响区间的合法性,所以

,减少一颗类型的石头会导致前面 的区间接下来失效,即 每次 时在 中找到 去更新答案即可 只需要使用任意一种能在单次 时间内增删查的数据结构维护即可 考虑更优的 (查): 如果 形如:,那么显然 的差距仅为 。 我们将所有的 都提前计算并排序去重,可以利用 个双指针知道每种 会更新到的新 在数组的哪个位置,相当于做了离散化将 映射成 ,用一个 的数组保存 的改变指向即可,每次可以 更新 ,所以查询的总复杂度降低到了 。(最开始为 在排序后的 中的位置) 增: 在查的基础上用一个数组 min_left[] 记录 的最远左边界 删: 在增查的基础上维护一个 vector<int> V[8][N],所以直接在 时,对 。可以证明即使 为负数越界到 也不会影响答案。

时,将 中记录的 pre-pos 所指向的最远左边界清零,然后清空 ,最多不会清理超过 次,所以总体复杂度为 。可以证明哪怕 pre-pos 又移动到被清理过的值, 后续再次清零它也不会影响答案。

#include <bits/stdc++.h>
constexpr int N = 7e5 + 27;
using Seven = std::array<int, 7>;
int a[N], _left[N], _ed = 1;Seven dt[2][N], *mp = dt[1];
std::vector<int> M[N];
signed main() {  
    int n, maxl = 0, L, R;  
    std::cin.tie(0)->sync_with_stdio(false);  
    std::cin >> n;  
    Seven cnt7{};  
    for (int i = 1; i <= n; ++ i) {    
        std::cin >> a[i];    
        if (a[i] > 0) 
            ++cnt7[a[i] - 1];    
        else 
            --cnt7[-a[i] - 1];    
        mp[++_ed] = cnt7;  
    }  
    std::sort(mp + 1, mp + _ed + 1); 
    _ed = std::unique(mp + 1, mp + _ed + 1) - mp - 1;  
    L = std::find(mp + 1, mp + _ed + 1, Seven{}) - mp; // 找到原点  
    Seven maxn{}, minn{}, cnt{};  
    std::array<int, 8> store_pos{};  
    for (int i = 1, r[7] = {1, 1, 1, 1, 1, 1, 1}; i <= _ed; ++ i) {    
        Seven next;    
        for (int j = 0; j < 7; ++ j) {      
            maxn[j] = std::max(maxn[j], mp[i][j]);      
            minn[j] = std::min(minn[j], mp[i][j]);      
            ++ mp[i][j];      
            while (r[j] < _ed && mp[r[j] + 1] <= mp[i]) 
                ++ r[j];      
            if (r[j] != i && mp[r[j]] == mp[i]) 
                next[j] = r[j], dt[0][r[j]][j] = i;      
            -- mp[i][j];    
        }    
        mp[i] = next;  
    }  
    for (int i = 0; i < 7; ++ i) {    
        store_pos[i + 1] = (store_pos[i] += -minn[i]) + maxn[i] + 1;  
    }  
    for (int i = 1, r_now = L, ai = std::abs(a[i]) - 1; i <= n; ai = std::abs(a[++i]) - 1) {   
        if (a[i] > 0) {      
            for (int j = 0; j < 7; ++ j) {        
                M[store_pos[j] + cnt[j]].push_back(r_now);      
            }      
            if (!_left[r_now]) 
                _left[r_now] = i;     
            ++cnt[ai], r_now = dt[1][r_now][ai];    
        } else {      
            auto &vec = M[store_pos[ai] + cnt[ai]];     
            for (int i : vec)
                _left[i] = 0;   
            vec.clear();   
            --cnt[ai], r_now = dt[0][r_now][ai];   
            if (_left[r_now] && i - _left[r_now] >= maxl) 
                L = _left[r_now], R = i, maxl = R - L + 1;    
        }  
    }  
    if (maxl) 
        std::cout << L << ' ' << R << '\n'; 
    else 
        std::cout << "QwQ\n";  
    return 0 ^ 0;
}

F. 少男少女成双对

此问题可以拆分为两个子问题。

子问题1:每个数字的出现次数小于等于2,可以用双指针维护。

子问题2:每个数字的出现次数为偶数次,可以用相同元素异或值为零的性质,对每一个数赋值一个比较大的随机值,然后异或哈希即可。

#include<bits/stdc++.h>

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	std::mt19937 rng(114514);

	int t;
	std::cin >> t;
	while (t--) {
		int n;
		std::cin >> n;
		std::vector<int> a(n + 1);
		for (int i = 1; i <= n; i++) {
			std::cin >> a[i];
		}

		std::map<int, std::pair<int, int>> bg;
		for (int i = 1; i <= n; i++) {
			if (bg.count(a[i]) == 0) {
				bg[a[i]] = {abs(rng()), abs(rng())};
			}
		}

		std::map<std::pair<int, int>, int> cnt;
		std::map<int, int> cnt_cnt;
		std::vector<std::pair<int,int>> sum(n + 1);
		cnt[ {1, 1}]++;
		sum[0] = {1, 1};
		int ans = 0;
		for (int i = 1, j = 1; i <= n; i++) {
			cnt_cnt[a[i]]++;
			while (j <= i && cnt_cnt[a[i]] > 2) {
				cnt[sum[j - 1]]--;
				cnt_cnt[a[j]]--;
				j++;
			}
			auto t = bg[a[i]];
			sum[i].first = t.first ^ sum[i - 1].first;
			sum[i].second = t.second ^ sum[i - 1].second;
			ans += cnt[sum[i]];
			cnt[sum[i]]++;
		}
		std::cout << ans << "\n";
	}

	return 0;
}

G. 匹配

理想理解: 考虑男生放在左边,女生放在右边,由于左边的每个点均链接两个右边的点,考虑重新建图。 对于左边的每一个点,他所链接的右边的俩个点连一条新边,那么每个点均有两条边, 个点, 条边,形成若干个环,每个点与他相连的一条边匹配。当选定一个点与他的一条边匹配之后,顺着可以将整个环所有的点匹配完,所以每个点均能匹配完。

感性理解: 假设每个人均只有一个人相连,那么每个人一定能匹配上,拓展来看,每个人均有两个人可以选择,条件严格宽泛于一个人可以选择,所以每个点均能匹配完。

最后答案输出

#include<bits/stdc++.h>

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int n;
	std::cin >> n;
	std::cout << n;

	return 0;
}

H. 传统艺能

A:钟井鸣海,皆川茜的结婚对象。

B:粟屋麦,喜欢皆川茜,最后和安乐冈花火走到一起。

C:白河月爱,加岛龙斗的女朋友。

D:吉田,荻原沙优的对象。

E:八重樱,跟卡莲贴贴。

F:卡莲·卡斯兰娜,跟八重樱贴贴。

G:绪方修,木更的契约者(男朋友)。

H:鸥端海苔子,粟屋麦的青梅竹马,单恋粟屋麦。

I:奥托·阿波卡利斯,卡莲的青梅竹马,单恋卡莲。

J:星野瑠美衣(露比),星野阿库亚的妹妹,喜欢星野阿库亚(因为喜欢阿库亚的前世)。

K:桂言叶,喜欢伊藤诚,伊藤诚死后杀了西园寺世界。

L:井浦基子,井浦秀的妹妹,暗恋同班同学北原。

M:荧,提瓦特海王,二创中的人间之屑,但此处没有其他提瓦特角色。

N:安乐冈花火,一直喜欢作为邻居的哥哥钟井鸣海,最后和粟屋麦走到一起。

O:伊藤诚,海王,喜欢桂言叶、西园寺世界等人,最后被西园寺世界所杀。

P:星野爱久爱海(阿库亚),星野露比的哥哥,究极妹控,前世被星野露比的前世救赎,并许下结婚的约定。

Q:皆川茜,海王,和粟屋麦、钟井鸣海等人都有关系。

R:加岛龙斗,白河月爱的男朋友。

S:木更,是绪方修的契约恶魔(现女友)。

T:北原:男同,井浦基子的同班同学,喜欢井浦基子的哥哥井浦秀。

U:荻原沙优,吉田的对象。

V:井浦秀,井浦基子的哥哥,妹控(但不是骨科),但他是正常人,不是男同。

W:绘鸠早苗,女同,喜欢安乐冈花火,桐岛笃也的表姐。

X:西园寺世界,喜欢伊藤诚,最后杀了伊藤诚。

Y:桐岛笃也,绘鸠早苗的表弟,喜欢绘鸠早苗。

因此答案为:

A:Q
B:NQ
C:R
D:U
E:F
F:E
G:S
H:B
I:F
J:P
K:O
L:T
M:NULL
N:AB
O:KX
P:J
Q:AB
R:C
S:G
T:V
U:D
V:NULL
W:N
X:O
Y:W

唉,二次元。

I. 没活了就咬打火姬

嘤嘤老赌狗,他说大家一定会为了题数+1而放弃看他咬打火姬。而且打火姬指的是安柏(opssw,呕

#include<bits/stdc++.h>

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	std::cout << "114514";

	return 0;
}

J. 小沙的悬崖

正常来说这是一个蜗牛爬树题,比如说 cf652A 或者 cf1810D。但是这是七夕赛,并且注意嘤嘤带恶人的三个输入变量都是 。众所都周知啊, 团一般___。所以这题输出 就可以过了。很喜欢嘤嘤的一句话“你只能说我数据水了,但不能说题目错了!”。

图片上传失败,请重新上传

btw,不要信题目的 Node,小沙和小雅现在很幸福。

#include<bits/stdc++.h>

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	std::cout << "-1";

	return 0;
}

K. 各色校等

输出西部枢纽。

注意到这句话含有“宁夏理工”子序列,因此输出NXIST即可,可以瞪眼得出。

也可以按题目要求搜索CCBC,看到今年CCBC13中有一道叫做“各色人等”的题目,该题目第一步就是从看似成语的句子中提取一些子序列。

祝伟大的ICPC西部枢纽永yi垂chou不wan朽nian,永远不jin死sai。

#include<bits/stdc++.h>

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	std::cout << "NXIST";

	return 0;
}

bonus:如果还没看过各色人等,不妨来看看下图瞪眼能得到哪些子序列(手动狗头)

alt

L. act as the input ,

根据题面提示,首先发现题目名字是"act as the input ,"(多了个逗号),然后注意到,输入描述里,正常的写法应该是,比如输入两个数字这样,但这里直接说第一个数、第二个数,少了对应的字母。

于是act作为input,再加上逗号,补全到输入描述里,其实输入的是

考虑字母的含义和数据范围,可以比较容易猜出ac是ac的题目数量,t是通过时间。

进而猜到本题是输入某队的过题数和罚时,输出其排名,没有这样的队输出

那是哪场比赛呢?根据题面第一句,鸡关注时事,所以就是近期的CCPC网络赛。

需要注意样例的提示,意思其实是:xcpcio的榜单不准,应以 http://ccpc.pintia.cn/basic.html 为准,且计算时不算打星队伍(点正式队伍)。

#include <bits/stdc++.h>

struct Rank {
    inline static int rank[13][2000];
    int operator()(int ac, int t) const noexcept {
        return rank[ac][t] ? rank[ac][t] : -1;
    }
    Rank& operator()(int ac, int t, int rk) noexcept {
        return rank[ac][t] = rk, *this;
    }
} rank;

signed main() {
    int T;
    std::cin.tie(0)->sync_with_stdio(false);
    std::cin >> T;
    rank(11,1682,1)(10,1545,2)(9,1457,3)(9,1536,4)(9,1607,5)(8,1391,6)(8,1431,7)(8,1437,8)(8,1586,9)(8,1685,10)(7,995,11)(7,1379,12)(7,1446,13)(7,1488,14)(7,1786,15)(6,784,16)(6,945,17)(6,1058,18)(6,1059,19)(6,1211,20)(6,1275,21)(6,1276,22)(6,1280,23)(6,1337,24)(6,1502,25)(5,617,26)(5,711,27)(5,748,28)(5,756,29)(5,787,30)(5,798,31)(5,823,32)(5,863,33)(5,881,34)(5,882,35)(5,952,36)(5,953,37)(5,992,38)(5,1021,39)(5,1051,40)(5,1067,41)(5,1083,42)(5,1324,43)(5,1545,44)(4,428,45)(4,440,46)(4,482,47)(4,493,48)(4,524,49)(4,551,50)(4,638,51)(4,655,52)(4,668,53)(4,677,54)(4,682,55)(4,701,56)(4,702,58)(4,708,59)(4,709,60)(4,711,61)(4,733,62)(4,735,63)(4,737,64)(4,743,65)(4,745,66)(4,748,67)(4,755,68)(4,757,70)(4,807,71)(4,812,72)(4,824,73)(4,828,74)(4,829,75)(4,836,76)(4,888,77)(4,890,78)(4,924,79)(4,930,80)(4,941,81)(4,952,82)(4,984,83)(4,986,84)(4,1004,85)(4,1016,86)(4,1065,87)(4,1073,88)(4,1089,89)(4,1095,90)(4,1162,91)(3,287,92)(3,296,93)(3,298,94)(3,316,95)(3,367,96)(3,369,97)(3,375,98)(3,381,99)(3,384,100)(3,398,101)(3,407,102)(3,419,103)(3,426,104)(3,432,105)(3,434,106)(3,452,107)(3,465,108)(3,466,109)(3,469,110)(3,474,111)(3,479,113)(3,482,114)(3,495,115)(3,501,116)(3,508,117)(3,510,118)(3,512,119)(3,526,120)(3,529,121)(3,533,122)(3,539,123)(3,540,124)(3,543,125)(3,550,127)(3,556,128)(3,560,129)(3,563,130)(3,565,131)(3,573,132)(3,574,133)(3,584,134)(3,586,135)(3,587,136)(3,588,137)(3,589,138)(3,591,139)(3,594,140)(3,596,141)(3,598,142)(3,599,143)(3,601,145)(3,602,146)(3,604,147)(3,622,148)(3,626,149)(3,630,150)(3,654,151)(3,656,152)(3,660,153)(3,666,154)(3,679,155)(3,690,156)(3,692,157)(3,694,158)(3,726,159)(3,737,160)(3,765,161)(3,793,162)(3,798,163)(3,836,164)(3,839,165)(3,870,166)(3,1011,167)(2,140,168)(2,142,169)(2,144,170)(2,151,171)(2,155,172)(2,161,173)(2,162,174)(2,163,175)(2,165,176)(2,167,177)(2,174,178)(2,188,179)(2,189,181)(2,195,184)(2,205,185)(2,208,186)(2,215,187)(2,221,188)(2,226,189)(2,227,190)(2,228,191)(2,229,192)(2,231,193)(2,238,194)(2,243,195)(2,245,196)(2,249,197)(2,250,198)(2,251,199)(2,253,201)(2,254,202)(2,255,203)(2,261,205)(2,270,206)(2,271,207)(2,273,208)(2,276,209)(2,279,210)(2,281,211)(2,285,214)(2,288,215)(2,289,216)(2,291,219)(2,298,220)(2,299,221)(2,300,223)(2,301,225)(2,303,226)(2,304,227)(2,306,228)(2,308,229)(2,309,230)(2,312,231)(2,316,234)(2,317,235)(2,318,236)(2,320,238)(2,324,239)(2,325,240)(2,328,241)(2,333,242)(2,337,244)(2,344,245)(2,345,246)(2,346,247)(2,348,248)(2,351,249)(2,353,251)(2,354,252)(2,356,253)(2,357,254)(2,358,256)(2,361,257)(2,365,258)(2,370,259)(2,371,260)(2,375,261)(2,376,262)(2,379,263)(2,384,265)(2,386,266)(2,387,267)(2,388,268)(2,389,269)(2,396,270)(2,397,271)(2,398,272)(2,401,273)(2,404,276)(2,405,277)(2,412,279)(2,417,280)(2,419,281)(2,420,282)(2,422,284)(2,423,286)(2,426,287)(2,430,288)(2,431,289)(2,432,290)(2,433,291)(2,440,292)(2,444,293)(2,448,294)(2,474,295)(2,478,296)(2,490,297)(2,498,298)(2,520,299)(2,533,300)(2,552,301)(2,557,302)(2,563,303)(2,565,304)(2,570,305)(2,578,306)(2,579,307)(2,591,308)(2,633,309)(2,650,310)(2,667,311)(2,724,312)(2,729,313)(2,1088,314)(2,1400,315)(1,12,316)(1,16,317)(1,17,318)(1,18,319)(1,19,321)(1,20,324)(1,21,328)(1,22,334)(1,23,335)(1,24,345)(1,25,351)(1,26,353)(1,27,357)(1,28,364)(1,29,374)(1,30,380)(1,31,389)(1,32,395)(1,33,399)(1,34,409)(1,35,416)(1,36,428)(1,37,434)(1,38,447)(1,39,458)(1,40,467)(1,41,479)(1,42,490)(1,43,501)(1,44,512)(1,45,518)(1,46,523)(1,47,527)(1,48,535)(1,49,546)(1,50,555)(1,51,561)(1,52,568)(1,53,578)(1,54,582)(1,55,587)(1,56,595)(1,57,605)(1,58,609)(1,59,619)(1,60,626)(1,61,632)(1,62,639)(1,63,647)(1,64,658)(1,65,663)(1,66,667)(1,67,672)(1,68,678)(1,69,687)(1,70,693)(1,71,703)(1,72,711)(1,73,713)(1,74,719)(1,75,723)(1,76,732)(1,77,744)(1,78,749)(1,79,751)(1,80,755)(1,81,761)(1,82,766)(1,83,772)(1,84,775)(1,85,782)(1,86,786)(1,87,797)(1,88,801)(1,89,807)(1,90,813)(1,91,818)(1,92,821)(1,93,826)(1,94,832)(1,95,836)(1,96,841)(1,97,843)(1,98,849)(1,99,859)(1,100,863)(1,101,870)(1,102,872)(1,103,879)(1,104,882)(1,105,888)(1,106,892)(1,107,895)(1,108,899)(1,109,903)(1,110,907)(1,111,912)(1,112,913)(1,113,916)(1,114,919)(1,115,927)(1,116,931)(1,117,938)(1,118,941)(1,119,943)(1,120,946)(1,121,949)(1,122,955)(1,123,956)(1,124,962)(1,125,968)(1,126,973)(1,127,977)(1,128,980)(1,129,982)(1,130,987)(1,132,990)(1,133,995)(1,134,1000)(1,135,1003)(1,136,1008)(1,137,1010)(1,138,1013)(1,139,1018)(1,140,1021)(1,141,1023)(1,142,1026)(1,143,1027)(1,144,1031)(1,145,1032)(1,146,1035)(1,147,1037)(1,148,1039)(1,149,1041)(1,150,1043)(1,151,1046)(1,152,1047)(1,153,1048)(1,154,1054)(1,155,1055)(1,156,1057)(1,157,1060)(1,158,1064)(1,159,1067)(1,160,1070)(1,161,1072)(1,162,1073)(1,163,1076)(1,164,1079)(1,165,1084)(1,166,1086)(1,167,1090)(1,168,1092)(1,169,1095)(1,171,1097)(1,172,1099)(1,173,1101)(1,174,1104)(1,175,1107)(1,176,1108)(1,177,1112)(1,178,1114)(1,179,1115)(1,180,1116)(1,182,1118)(1,183,1119)(1,184,1120)(1,185,1121)(1,186,1122)(1,187,1124)(1,188,1127)(1,189,1128)(1,190,1130)(1,192,1133)(1,193,1135)(1,195,1138)(1,196,1139)(1,199,1142)(1,200,1144)(1,201,1145)(1,203,1148)(1,204,1151)(1,205,1154)(1,206,1155)(1,207,1157)(1,209,1158)(1,210,1159)(1,211,1160)(1,212,1163)(1,213,1164)(1,214,1166)(1,215,1168)(1,216,1169)(1,217,1170)(1,218,1171)(1,219,1172)(1,221,1173)(1,223,1174)(1,224,1176)(1,225,1178)(1,229,1181)(1,231,1183)(1,233,1184)(1,234,1185)(1,236,1187)(1,237,1188)(1,238,1190)(1,239,1191)(1,240,1192)(1,241,1193)(1,243,1194)(1,244,1197)(1,245,1198)(1,247,1199)(1,248,1202)(1,253,1204)(1,254,1207)(1,255,1208)(1,256,1209)(1,257,1210)(1,258,1211)(1,259,1214)(1,262,1215)(1,263,1219)(1,266,1220)(1,269,1224)(1,273,1226)(1,274,1227)(1,275,1228)(1,277,1230)(1,278,1231)(1,280,1232)(1,281,1235)(1,282,1236)(1,286,1237)(1,287,1240)(1,289,1242)(1,290,1243)(1,292,1244)(1,295,1245)(1,299,1246)(1,302,1248)(1,304,1249)(1,305,1250)(1,307,1251)(1,308,1253)(1,309,1255)(1,310,1256)(1,313,1257)(1,315,1258)(1,319,1259)(1,321,1261)(1,323,1264)(1,326,1265)(1,328,1267)(1,334,1268)(1,335,1270)(1,338,1272)(1,339,1273)(1,345,1274)(1,348,1275)(1,352,1276)(1,353,1277)(1,357,1278)(1,362,1279)(1,368,1280)(1,387,1282)(1,388,1283)(1,390,1284)(1,393,1286)(1,402,1287)(1,405,1288)(1,415,1289)(1,416,1290)(1,417,1291)(1,418,1292)(1,421,1293)(1,425,1294)(1,429,1295)(1,434,1296)(1,452,1297)(1,465,1298)(1,468,1299)(1,518,1300)(1,558,1301)(1,576,1302)(0,0,1303);
    std::cout << '\n';
    while (T --) {
        int a, b;
        std::cin >> a >> b;
        std::cout << rank(a, b) << '\n';
    }
    
    return 0;
}

M. 小红的h++2.0.1

A=B 实在是太好玩了!!!!

php大法好啊,注意顺序奥。

change("aa","a");
change("bb","b");
change("cc","c");
change("ba","ab");
change("ca","ac");
change("cb","bc");
change("abc","3");
change("ab","2");
change("bc","2");
change("ac","2");
change("a","1");
change("b","1");
change("c","1");

C++

#include<bits/stdc++.h>

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	auto change = [&](string a, string b) {
		cout << "change(\"" << a << "\",\"" << b << "\");\n";
	};
	change("ba", "ab");
	change("ca", "ac");
	change("cb", "bc");
	change("aa", "a");
	change("bb", "b");
	change("cc", "c");

	change("abc", "3");
	change("ab", "2");
	change("ac", "2");
	change("a", "1");
	change("bc", "2");
	change("b", "1");
	change("c", "1");

	return 0;
}