QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#112276#6569. Splitting PairsITMO_pengzoo#AC ✓10ms3736kbC++203.7kb2023-06-11 01:09:532023-06-11 01:09:56

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-11 01:09:56]
  • 评测
  • 测评结果:AC
  • 用时:10ms
  • 内存:3736kb
  • [2023-06-11 01:09:53]
  • 提交

answer

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("unroll-loops")

#include <stdio.h>
#include <bits/stdc++.h>

#ifdef PERVEEVM_LOCAL
    #define debug(x) std::cerr << (#x) << ":\t" << (x) << std::endl
#else
    #define debug(x) 238
#endif

#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define NAME "File"

using ll = long long;
using ld = long double;

#ifdef PERVEEVM_LOCAL
    std::mt19937 rnd(238);
#else
    std::mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

template<typename T1, typename T2>
std::ostream& operator<<(std::ostream& out, const std::pair<T1, T2>& p) {
    out << "(" << p.first << ", " << p.second << ")";
    return out;
}

template<size_t index, typename T>
std::ostream& print_tuple(std::ostream& out, const T& t) {
    if constexpr (index == std::tuple_size<T>::value) {
        out << ")";
        return out;
    } else {
        if (index > 0) {
            out << ", ";
        } else {
            out << "(";
        }
        out << std::get<index>(t);
        return print_tuple<index + 1, T>(out, t);
    }
}

template<typename ...T>
std::ostream& operator<<(std::ostream& out, const std::tuple<T...>& t) {
    return print_tuple<0, std::tuple<T...>>(out, t);
}

template<typename Container, typename = decltype(std::begin(std::declval<Container>()))>
typename std::enable_if<!std::is_same<Container, std::string>::value, std::ostream&>::type
operator<<(std::ostream& out, const Container& container) {
    out << "{";
    for (auto it = container.begin(); it != container.end(); ++it) {
        if (it != container.begin()) {
            out << ", ";
        }
        out << *it;
    }
    out << "}";
    return out;
}

template<typename T>
bool smin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool smax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const double PI = atan2(0.0, -1.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
const int N = 55;

ll a[N];

void solve() {
	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; ++i) {
		scanf("%lld", &a[i]);
	}

	if (n % 2 == 0) {
		bool allOdd = true;
		for (int i = 0; i < n; ++i) {
			if (a[i] % 2 == 0) {
				allOdd = false;
			}
		}

		if (allOdd) {
			printf("0\n");
		} else {
			printf("1\n");
		}
	} else {
		while (true) {
			bool allEven = true;
			for (int i = 0; i < n; ++i) {
				if (a[i] % 2 == 1) {
					allEven = false;
				}
			}

			if (!allEven) {
				break;
			}
			for (int i = 0; i < n; ++i) {
				a[i] /= 2;
			}
		}

		bool allOdd = true;
		for (int i = 0; i < n; ++i) {
			if (a[i] % 2 == 0) {
				allOdd = false;
			}
		}

		if (allOdd) {
			printf("0\n");
		} else {
			printf("1\n");
		}
	}
}

void run() {
	int t;
	scanf("%d", &t);

	while (t--) {
		solve();
	}    
}

int main(void) {
    // freopen(NAME".in", "r", stdin);
    // freopen(NAME".out", "w", stdout);

    #ifdef PERVEEVM_LOCAL
        auto start = std::chrono::high_resolution_clock::now();
    #endif

    run();

    #ifdef PERVEEVM_LOCAL
        auto end = std::chrono::high_resolution_clock::now();
        std::cerr << "Execution time: "
                  << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
                  << " ms" << std::endl;
    #endif

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3456kb

input:

4
3
1 1 1
3
1 1 2
3
2 2 2
4
4 4 4 4

output:

0
1
0
1

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 2ms
memory: 3460kb

input:

1000
10
16 16 16 16 16 16 16 16 16 16
10
16 16 16 16 16 16 16 16 17 16
10
16 16 16 16 16 16 16 18 16 16
10
16 16 16 19 16 16 16 16 16 16
10
16 16 16 16 20 16 16 16 16 16
10
17 16 16 16 17 16 16 16 16 16
10
16 16 16 16 16 16 16 16 18 17
10
16 16 19 16 16 16 16 17 16 16
10
17 16 16 16 16 16 16 20 16 1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 1000 lines

Test #3:

score: 0
Accepted
time: 2ms
memory: 3736kb

input:

1000
2
4 4
2
5 4
2
4 6
2
7 4
2
4 8
2
5 5
2
6 5
2
7 5
2
8 5
2
6 6
2
7 6
2
8 6
2
7 7
2
7 8
2
8 8
3
4 4 4
3
4 5 4
3
4 4 6
3
4 7 4
3
8 4 4
3
4 5 5
3
6 4 5
3
4 5 7
3
8 5 4
3
6 4 6
3
7 4 6
3
8 4 6
3
4 7 7
3
7 8 4
3
8 8 4
3
5 5 5
3
5 6 5
3
5 5 7
3
5 8 5
3
6 5 6
3
6 7 5
3
6 5 8
3
7 7 5
3
8 5 7
3
5 8 8
3
6 6...

output:

1
1
1
1
1
0
1
0
1
1
1
1
0
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
0
1
1
0
1
1
1
1
1
0
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
0
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 1000 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

1000
3
4 4 4
3
4 5 4
3
4 6 4
3
4 7 4
3
4 4 8
3
5 4 5
3
4 5 6
3
5 4 7
3
4 8 5
3
4 6 6
3
6 4 7
3
6 4 8
3
7 7 4
3
4 7 8
3
8 4 8
3
5 5 5
3
5 6 5
3
5 7 5
3
5 8 5
3
6 5 6
3
7 5 6
3
8 6 5
3
7 7 5
3
7 5 8
3
8 8 5
3
6 6 6
3
6 7 6
3
8 6 6
3
7 7 6
3
6 8 7
3
8 6 8
3
7 7 7
3
7 7 8
3
8 8 7
3
8 8 8
5
4 4 4 4 4
5
4...

output:

0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
0
1
1
0
1
1
1
1
1
0
1
1
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
0
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
0
1
1
1
1
1
1
1
1
1
...

result:

ok 1000 lines

Test #5:

score: 0
Accepted
time: 10ms
memory: 3620kb

input:

1000
49
70984400896 988463235072 689895899136 448069107712 139972313088 432801841152 571884961792 572723822592 147287179264 253252075520 941688356864 914542821376 100344528896 317945020416 796062121984 504306335744 30417092608 36054237184 652314935296 547994206208 335393325056 959203770368 824583389...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 lines

Test #6:

score: 0
Accepted
time: 3ms
memory: 3456kb

input:

1000
49
70492821504 404687910912 805429737472 657584551936 442074908672 204355868672 763966863360 396972795904 831477815296 928168810496 299311560704 748747630592 727295735808 22145292288 324382889984 95878944768 714705733632 301275334656 282344843264 158970316800 536299845632 89674733568 3273064878...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 lines

Test #7:

score: 0
Accepted
time: 8ms
memory: 3584kb

input:

1000
50
831747260416 348831875072 22145925120 740210769920 728399609856 59458453504 476607152128 683034017792 993076969472 614046105600 326820167680 485197086720 157168959488 490297360384 651627069440 187770601472 746384785408 685986807808 665585713152 562238062592 459158847488 173543522304 65296924...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
...

result:

ok 1000 lines