训练日记2019.10.26 再出发

2019.10.26 星期六
昨天和同学去吃完烤肉,看着窗外落下的夜幕,我知道我的秋假结束了,朋友打趣道,怎么你吃了顿烤肉秋假就结束了???不过我知道,能这么两天放开的玩,是因为我之前所干了的三个月,还有一个月,继续加油搞下去,就是胜利,只是可能大二的gpa今年又要不保了,不过,尽人事听天命,总是没错。

今天写了道洛谷的图论dfs求环的长度,还有codeforces div3,这道题真是水题,我刚开始还以为这道题挺难,写了个lis,后面突然想到了个比较猥琐的方法,我大胆猜测这题的输出结果只有1和2,好嘛,果然就是这样,直接ac哈哈哈哈,棒棒哒!今天早点撤退,我还要享受下最后的假期呢,其实就是出去走走,然后买个冰激淋然后再回来。
题解 codeforces div3 t1
太简单了,不过回复下手感和脑子还不错的。(传送门

#include <bits/stdc++.h>
using namespace std;
#define limit 20000 + 5//防止溢出
#define INF 0x3f3f3f3f
#define inf 1<<20
#define lowbit(i) i&(-i)//一步两步
#define EPS 1e-6
#define ff(a) printf("%d\n",a );
#define MOD 1e9 + 7
typedef long long ll;
void read(int &x){
    char ch = getchar();x = 0;
    for (; ch < '0' || ch > '9'; ch = getchar());
    for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}//快读
vector<int>v;
int kase, n;
int dp[limit];
int main(){
    //freopen("C:\\Users\\administrator01\\CLionProjects\\untitled14\\data.txt", "rt" , stdin);
    scanf("%d", &kase);
    while(kase--){
        scanf("%d" , &n);
        v.clear();
        for(int i = 0 ; i < n ; ++i){
            int val;
            scanf("%d" , &val);
            v.push_back(val);
            dp[i] = 1;
        }
        dp[n] = 1;
        sort(v.begin(), v.end());
        int ans = 0;
        for(int i = 1 ; i < v.size() ; ++i){
            if(abs(v[i] - v[i - 1]) == 1){
                dp[i] = dp[i - 1] + 1;
                ans = max(ans ,dp[i]);
            }
        }
        ff(ans == 0 ? 1 : 2)
    }
    return 0;
}
发布了69 篇原创文章 · 获赞 1 · 访问量 3039

猜你喜欢

转载自blog.csdn.net/Stagflation/article/details/102763477