日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))

發布時間:2023/12/3 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))

題號題目知識點
ASimply Strange Sort暴力
BCharmed by the Game
CDeep Down Below
D1Up the Strip (simplified version)
D2Up the Strip
EBottom-Tier Reversals
FTop-Notch Insertions

A

直接暴力就行,n才999

// Problem: A. Simply Strange Sort // Contest: Codeforces - Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) // URL: https://codeforces.com/contest/1561/problem/A // Memory Limit: 512 MB // Time Limit: 2000 ms // Data:2021-08-24 22:38:22 // By Jozky#include <bits/stdc++.h> #include <unordered_map> #define debug(a, b) printf("%s = %d\n", a, b); using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> PII; clock_t startTime, endTime; //Fe~Jozky const ll INF_ll= 1e18; const int INF_int= 0x3f3f3f3f; void read(){}; template <typename _Tp, typename... _Tps> void read(_Tp& x, _Tps&... Ar) {x= 0;char c= getchar();bool flag= 0;while (c < '0' || c > '9')flag|= (c == '-'), c= getchar();while (c >= '0' && c <= '9')x= (x << 3) + (x << 1) + (c ^ 48), c= getchar();if (flag)x= -x;read(Ar...); } template <typename T> inline void write(T x) {if (x < 0) {x= ~(x - 1);putchar('-');}if (x > 9)write(x / 10);putchar(x % 10 + '0'); } void rd_test() { #ifdef LOCALstartTime= clock();freopen("in.txt", "r", stdin); #endif } void Time_test() { #ifdef LOCALendTime= clock();printf("\nRun Time:%lfs\n", (double)(endTime - startTime) / CLOCKS_PER_SEC); #endif } const int maxn= 2000; int a[maxn]; int main() {//rd_test();int t;read(t);while (t--) {int n;read(n);memset(a, 0, sizeof(a));for (int i= 1; i <= n; i++)read(a[i]);bool f= 1;for (int i= 1; i < n; i++) {if (a[i] > a[i + 1]) {f= 0;break;}}if (f == 1) {printf("0\n");continue;}for (int i= 1;; i++) {if (i & 1) { //如果i是奇數for (int j= 1; j < n; j+= 2) {if (a[j] > a[j + 1])swap(a[j], a[j + 1]);}}else {for (int j= 2; j < n; j+= 2) {if (a[j] > a[j + 1])swap(a[j], a[j + 1]);}}bool f= 1;for (int j= 1; j < n; j++) {if (a[j] > a[j + 1]) //存在逆序{f= 0;break;}}if (f) {printf("%d\n", i);break;}}}return 0;//Time_test(); }

總結

以上是生活随笔為你收集整理的Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))的全部內容,希望文章能夠幫你解決所遇到的問題。

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