Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))
Posted Jozky86
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))相关的知识,希望对你有一定的参考价值。
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 LOCAL
startTime= clock();
freopen("in.txt", "r", stdin);
#endif
}
void Time_test()
{
#ifdef LOCAL
endTime= 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))的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #740 Div. 2 A B C D1 D2
Codeforces Round #740 Div. 2 A B C D1 D2
Codeforces Round #740 (Div. 2) D1. Up the Strip (simplified version)
Codeforces Round #740 (Div. 2) D1. Up the Strip (simplified version)
Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))
Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))ABCD1D2E题解