Task: | Pyramidi |
Sender: | tsiki2 |
Submission time: | 2020-11-29 22:56:25 +0200 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 17 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 17 |
#2 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2 | details |
#2 | ACCEPTED | 0.01 s | 1, 2 | details |
#3 | ACCEPTED | 0.01 s | 1, 2 | details |
#4 | ACCEPTED | 0.01 s | 1, 2 | details |
#5 | ACCEPTED | 0.01 s | 1, 2 | details |
#6 | ACCEPTED | 0.01 s | 1, 2 | details |
#7 | ACCEPTED | 0.01 s | 1, 2 | details |
#8 | ACCEPTED | 0.01 s | 1, 2 | details |
#9 | ACCEPTED | 0.01 s | 1, 2 | details |
#10 | ACCEPTED | 0.01 s | 1, 2 | details |
#11 | ACCEPTED | 0.01 s | 1, 2 | details |
#12 | ACCEPTED | 0.01 s | 1, 2 | details |
#13 | ACCEPTED | 0.01 s | 1, 2 | details |
#14 | ACCEPTED | 0.01 s | 1, 2 | details |
#15 | ACCEPTED | 0.01 s | 1, 2 | details |
#16 | TIME LIMIT EXCEEDED | -- | 2 | details |
#17 | TIME LIMIT EXCEEDED | -- | 2 | details |
#18 | TIME LIMIT EXCEEDED | -- | 2 | details |
#19 | TIME LIMIT EXCEEDED | -- | 2 | details |
#20 | TIME LIMIT EXCEEDED | -- | 2 | details |
Compiler report
input/code.cpp: In function 'int solve(std::vector<int>&)': input/code.cpp:101:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < a.size(); i++) { ~~^~~~~~~~~~ input/code.cpp:100:6: warning: unused variable 'nom_twos' [-Wunused-variable] int nom_twos = cum_twos[n]; ^~~~~~~~
Code
#include <stdio.h> // include before iostream for faster scanf#include <iostream>#include <vector>#include <string>#include <map>#include <unordered_map>#include <algorithm>#include <utility>#include <set>#include <unordered_set>#include <cmath>#include <math.h>#include <queue>#include <stdlib.h>#include <string.h>#include <sstream>#include <tuple>#include <utility>#include <iomanip>#include <iterator>using namespace std;typedef long long LL;#define printv(printVec) for (auto printVecIter : (printVec)) cout << printVecIter << " "; cout << endl;// g++ -Wall -Wshadow -std=c++11 a.cpp && ./a.outvector<int> twos_per_num;vector<int> cum_twos;int twos(int n) {int ans = 0;while ((n%2) == 0 && n>1) {ans++;n/= 2;}return ans;}long long degree(long long a, long long k, long long p) {long long res = 1;long long cur = a;while (k) {if (k % 2) {res = (res * cur) % p;}k /= 2;cur = (cur * cur) % p;}return res;}LL get_degree(long long n, long long p) { // returns the degree with which p is in n!LL degree_num = 0;long long u = p;long long temp = n;while (u <= temp) {degree_num += temp / u;u *= p;}return degree_num;}long long combinations(LL n, LL k, long long p) {LL num_degree = get_degree(n, p) - get_degree(n - k, p);LL den_degree = get_degree(k, p);if (num_degree > den_degree) {return 0;}long long res = 1;for (long long i = n; i > n - k; --i) {long long ti = i;while(ti % p == 0) {ti /= p;}res = (res * ti) % p;}for (long long i = 1; i <= k; ++i) {long long ti = i;while(ti % p == 0) {ti /= p;}res = (res * degree(ti, p-2, p)) % p;}return res;}int solve(vector<int> & a) {int n = a.size() - 1;int ans = 0;int nom_twos = cum_twos[n];for (int i = 0; i < a.size(); i++) {if (combinations(n, i, 2) == 1) {ans ^= a[i];}// int d1 = i;// int d2 = a.size() - i - 1;// int dist = min(d1, d2);// int div = cum_twos[dist] + cum_twos[n-i];// if (nom_twos == div || dist == 0) {// // cout << a[i] << endl;// }}return ans;}int main() {std::ios::sync_with_stdio(false);cin.tie(0);int n;cin >> n;int cumsum = 0;for (int i = 0; i < 200000; i++) {int t = twos(i);twos_per_num.push_back(t);cumsum += t;cum_twos.push_back(cumsum);}// cout << "\n"<< cum_twos[2] << " xx " <<cum_twos[5]<<endl;vector<int> a(n);for (int i=0; i <n;i++) {cin>>a[i];}cout << solve(a) << endl;}
Test details
Test 1
Group: 1, 2
Verdict: ACCEPTED
input |
---|
1 80 |
correct output |
---|
80 |
user output |
---|
80 |
Test 2
Group: 1, 2
Verdict: ACCEPTED
input |
---|
2 69 91 |
correct output |
---|
30 |
user output |
---|
30 |
Test 3
Group: 1, 2
Verdict: ACCEPTED
input |
---|
3 47 74 75 |
correct output |
---|
100 |
user output |
---|
100 |
Test 4
Group: 1, 2
Verdict: ACCEPTED
input |
---|
4 94 22 100 43 |
correct output |
---|
7 |
user output |
---|
7 |
Test 5
Group: 1, 2
Verdict: ACCEPTED
input |
---|
5 50 82 47 40 51 |
correct output |
---|
1 |
user output |
---|
1 |
Test 6
Group: 1, 2
Verdict: ACCEPTED
input |
---|
6 90 27 98 85 47 14 |
correct output |
---|
96 |
user output |
---|
96 |
Test 7
Group: 1, 2
Verdict: ACCEPTED
input |
---|
7 55 82 52 9 65 90 86 |
correct output |
---|
20 |
user output |
---|
20 |
Test 8
Group: 1, 2
Verdict: ACCEPTED
input |
---|
8 45 52 52 95 40 85 3 46 |
correct output |
---|
34 |
user output |
---|
34 |
Test 9
Group: 1, 2
Verdict: ACCEPTED
input |
---|
9 77 16 59 32 22 41 87 89 78 |
correct output |
---|
3 |
user output |
---|
3 |
Test 10
Group: 1, 2
Verdict: ACCEPTED
input |
---|
10 59 78 34 26 71 9 82 68 80 74 |
correct output |
---|
111 |
user output |
---|
111 |
Test 11
Group: 1, 2
Verdict: ACCEPTED
input |
---|
100 100 6 10 53 84 80 7 87 3 82 26... |
correct output |
---|
91 |
user output |
---|
91 |
Test 12
Group: 1, 2
Verdict: ACCEPTED
input |
---|
100 25 18 62 51 79 55 71 33 21 29 ... |
correct output |
---|
58 |
user output |
---|
58 |
Test 13
Group: 1, 2
Verdict: ACCEPTED
input |
---|
100 3 20 19 60 11 84 94 79 63 59 9... |
correct output |
---|
124 |
user output |
---|
124 |
Test 14
Group: 1, 2
Verdict: ACCEPTED
input |
---|
100 99 86 42 2 97 78 8 12 98 7 98 ... |
correct output |
---|
49 |
user output |
---|
49 |
Test 15
Group: 1, 2
Verdict: ACCEPTED
input |
---|
100 19 19 14 30 80 53 21 18 26 85 ... |
correct output |
---|
42 |
user output |
---|
42 |
Test 16
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 852837035 608724072 368935143 ... |
correct output |
---|
680579671 |
user output |
---|
(empty) |
Test 17
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 255817977 550740070 115276527 ... |
correct output |
---|
177586289 |
user output |
---|
(empty) |
Test 18
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 30889540 9467827 526159961 367... |
correct output |
---|
439343644 |
user output |
---|
(empty) |
Test 19
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 421000302 598694653 199802169 ... |
correct output |
---|
184880259 |
user output |
---|
(empty) |
Test 20
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 578873143 289492857 855880936 ... |
correct output |
---|
937457144 |
user output |
---|
(empty) |