日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

CF 1550C

發布時間:2024/3/26 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CF 1550C 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

鏈接這里

題意:在區間內選取三個點,若兩個點曼哈頓距離與XXX相等,則為Bad,否則為Good;
推一下可以發現,超過4個點,那么這個區間必為Bad,我們只需要枚舉3個點與四個點是否為Bad就行。

#include<bits/stdc++.h>using namespace std;#define int long long #define gcd(a, b) __gcd(a,b) const long long mod = 1e9 + 7; const int maxn = 1e5 + 5;signed main() {cin.tie(nullptr)->sync_with_stdio(false);int t;cin >> t;while (t--) {int n;cin >> n;vector<int> a(n);int num = 0;for (int i = 0; i < n; ++i) {cin >> a[i];}for (int i = 0; i < n - 2; ++i) {if (a[i + 1] <= max(a[i + 2], a[i]) && a[i + 1] >= min(a[i], a[i + 2]));else {num++;}}for (int i = 0; i < n - 3; ++i) {if ((a[i + 1] <= max(a[i], a[i + 3]) && a[i + 1] >= min(a[i], a[i + 3])) ||(a[i + 2] <= max(a[i], a[i + 3]) && a[i + 2] >= min(a[i], a[i + 3])) ||(a[i + 1] <= max(a[i + 2], a[i]) && a[i + 1] >= min(a[i + 2], a[i])) ||(a[i + 2] <= max(a[i + 1], a[i + 3]) && a[i + 2] >= min(a[i + 1], a[i + 3])));// cout << a[i] << ' ' << a[i + 1] << ' ' << a[i + 2] << endl;else {//cout << a[i] << endl;num++;}}cout << num + 2 * n - 1 << endl;}return 0; }

總結

以上是生活随笔為你收集整理的CF 1550C的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。