作用:
弥补了main函数里面不可以定义函数的缺陷,减少了全局变量的声明
可以在main里面搭建小的构件,如下:
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define int long long
#define loop(n) for(int i=0;i<n;i++)
#define rloop(n) for(int i=n-1;i>=0;i--)
#define print(c) cout<<"this "#c" is "<<c<<endl;
#define MAX INT_MAX
#define MIN INT_MIN
const int N = 1010;
using namespace std;
void solve() {
int n = 10;
int a[10] = { 1,2,3,4,5,6,7,7,8,9 };
auto check = [&](int j, int i) {//用来查重
map<int, int> m;
for (; j <= i; j++)
if (m[a[j]] == 1)return 0;
else m[a[j]]++;
return 1;
};
auto f1 = [&]() {//用于返回最大的不重复子序列
int count = 0;//窗口长度
for (int i = 0,j=0; i < n; i++) {
if (