Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))
生活随笔
收集整理的這篇文章主要介紹了
Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))
| A | Simply Strange Sort | 暴力 |
| B | Charmed by the Game | |
| C | Deep Down Below | |
| D1 | Up the Strip (simplified version) | |
| D2 | Up the Strip | |
| E | Bottom-Tier Reversals | |
| F | Top-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是奇數(shù)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(); }總結(jié)
以上是生活随笔為你收集整理的Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 紫丹参的功效与作用
- 下一篇: 小孩用抗感颗粒的作用