正文
增加 12 行删除 15 行
36 行未改动37383940414243444548 行未改动9495969798991001011025 行未改动108109110111112113114115116110 行未改动全部展开227228229230231232233234235236237238239240241242243244132 行未改动全部展开37737837938038138238338431 行未改动41641741841942042142242342442542642742842943043143243343443543643743843944036 行未改动#include <bits/stdc++.h>using namespace std;int main() {string c1, s1, c2, s2;cin >> c1 >> s1 >> c2 >> s2;if (s1[2] == 'F') s1[2] = 'E';if (s2[2] == 'F') s2[2] = 'E';48 行未改动```cpp#include <bits/stdc++.h>#define int long long#define qwq ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)using namespace std;const int N = 2e5+5;5 行未改动int n;P a[N];signed main() {qwq;cin >> n;for (int i=1; i<=n; i++) {cin >> a[i].x >> a[i].c;}110 行未改动全部展开```cpp#include <bits/stdc++.h>#define int long long#define qwq ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)using namespace std;const int N = 2e5+5;int n, m, a[N], res = 0;int flag[N]; // 标记不可选数字,1表示不可选signed main() {qwq;cin >> n >> m;for (int i=1; i<=n; i++) {cin >> a[i];}132 行未改动全部展开}}signed main() {cin >> n >> m;for (int i=1; i<=n; i++) {cin >> a[i];last[a[i]] = i;31 行未改动int f[N]; // f[i]表示第i个位置的经过次数,这里应该只统计每个数字最后一次出现的位置// last[i]记录数字最后一次出现的位置signed main() {qwq;cin >> n >> m;for (int i=1; i<=n; i++) {cin >> a[i];last[a[i]] = i;c[a[i]]++;}for (int i=1; i<=m; i++) f[last[i]] = c[i]; // 初始状态// 这里是必须正序循环,保证最前面的last[a[i]]先进行转移,也就是拓扑序。for (int i=1; i<n; i++) {if (i == last[a[i]]) {int j = last[a[i+1]]; // 下一个跳转的位置f[j] += f[i];}}for (int i=1; i<=m; i++) cout << f[last[i]] << " ";return 0;}```36 行未改动373839404142434448 行未改动939495969798991005 行未改动106107108109110111112113110 行未改动全部展开224225226227228229230231232233234235236237238239240132 行未改动全部展开37337437537637737837938038131 行未改动41341441541641741841942042142242342442542642742842943043143243343443543643736 行未改动#include <bits/stdc++.h>using namespace std;int main() {string c1, s1, c2, s2;cin >> c1 >> s1 >> c2 >> s2;if (s1[2] == 'F') s1[2] = 'E';if (s2[2] == 'F') s2[2] = 'E';48 行未改动```cpp#include <bits/stdc++.h>#define int long longusing namespace std;const int N = 2e5+5;5 行未改动int n;P a[N];signed main() {cin >> n;for (int i=1; i<=n; i++) {cin >> a[i].x >> a[i].c;}110 行未改动全部展开```cpp#include <bits/stdc++.h>#define int long longusing namespace std;const int N = 2e5+5;int n, m, a[N], res = 0;int flag[N]; // 标记不可选数字,1表示不可选signed main() {ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);;cin >> n >> m;for (int i=1; i<=n; i++) {cin >> a[i];}132 行未改动全部展开}}signed main() {ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);cin >> n >> m;for (int i=1; i<=n; i++) {cin >> a[i];last[a[i]] = i;31 行未改动int f[N]; // f[i]表示第i个位置的经过次数,这里应该只统计每个数字最后一次出现的位置// last[i]记录数字最后一次出现的位置signed main() {ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);cin >> n >> m;for (int i=1; i<=n; i++) {cin >> a[i];last[a[i]] = i;c[a[i]]++;}for (int i=1; i<=m; i++) f[last[i]] = c[i]; // 初始状态// 这里是必须正序循环,保证最前面的last[a[i]]先进行转移,也就是拓扑序。for (int i=1; i<n; i++) {if (i == last[a[i]]) {int j = last[a[i+1]]; // 下一个跳转的位置f[j] += f[i];}}for (int i=1; i<=m; i++) cout << f[last[i]] << " ";return 0;}```