Submission #4260491


Source Code Expand

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define rg register
#define LL long long
#define __space putchar(' ')
#define __endl putchar('\n')
template <typename qwq> inline void read(qwq & x)
{
    x = 0;
    rg int f = 1;
    rg char c = getchar();
    while (c < '0' || c > '9')
    {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
    {
        x = (x << 1) + (x << 3) + (c ^ 48);
        c = getchar();
    }
    x *= f;
}
template <typename qaq> inline void print(qaq x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}
struct node
{
	int val,data;
}a[233333];
int n;
LL ans;
bitset<1000000005> s;
inline bool cmp(node x,node y)
{
	return x.val < y.val;
}
int main()
{
	read(n);
	ans = n;
	for (rg int i = 1;i <= n;++i)
	{
		read(a[i].val);
		a[i].data = i;
	}
	stable_sort(a + 1,a + 1 + n,cmp);
	for (rg int i = 1;i <= n;++i)
	{
		if (s[a[i].val]) continue;
		rg bool odd_i = i & 1,odd_data = a[i].data & 1;
		if (odd_i == odd_data) s[a[i].val] = true,--ans;
	}
	print(ans >> 1);
}

Submission Info

Submission Time
Task C - BBuBBBlesort!
User vjudge4
Language C++14 (GCC 5.4.1)
Score 600
Code Size 1247 Byte
Status AC
Exec Time 43 ms
Memory 123128 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 2
AC × 24
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt AC 43 ms 123128 KB
02.txt AC 43 ms 123128 KB
03.txt AC 43 ms 123128 KB
04.txt AC 43 ms 123128 KB
05.txt AC 16 ms 2688 KB
06.txt AC 16 ms 2688 KB
07.txt AC 16 ms 2688 KB
08.txt AC 9 ms 2688 KB
09.txt AC 9 ms 2688 KB
10.txt AC 10 ms 2688 KB
11.txt AC 10 ms 2688 KB
12.txt AC 9 ms 2688 KB
13.txt AC 9 ms 2688 KB
14.txt AC 15 ms 2688 KB
15.txt AC 15 ms 2688 KB
16.txt AC 15 ms 2688 KB
17.txt AC 16 ms 4344 KB
18.txt AC 2 ms 2304 KB
19.txt AC 2 ms 2304 KB
20.txt AC 2 ms 2304 KB
21.txt AC 2 ms 2304 KB
22.txt AC 2 ms 2304 KB
s1.txt AC 2 ms 2304 KB
s2.txt AC 2 ms 2304 KB