Task: | Kyselyt |
Sender: | Lieska |
Submission time: | 2025-10-18 18:30:08 +0300 |
Language: | C++ (C++20) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
#4 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.04 s | 1, 2, 3, 4 | details |
#2 | WRONG ANSWER | 0.04 s | 1, 2, 3, 4 | details |
#3 | ACCEPTED | 0.04 s | 1, 3, 4 | details |
#4 | WRONG ANSWER | 0.38 s | 2, 3, 4 | details |
#5 | WRONG ANSWER | 0.41 s | 2, 3, 4 | details |
#6 | WRONG ANSWER | 0.34 s | 2, 3, 4 | details |
#7 | TIME LIMIT EXCEEDED | -- | 3, 4 | details |
#8 | WRONG ANSWER | 0.79 s | 4 | details |
#9 | WRONG ANSWER | 0.86 s | 4 | details |
#10 | TIME LIMIT EXCEEDED | -- | 4 | details |
#11 | TIME LIMIT EXCEEDED | -- | 3, 4 | details |
#12 | TIME LIMIT EXCEEDED | -- | 4 | details |
#13 | WRONG ANSWER | 0.33 s | 3, 4 | details |
#14 | WRONG ANSWER | 0.65 s | 4 | details |
#15 | WRONG ANSWER | 0.81 s | 4 | details |
#16 | WRONG ANSWER | 0.82 s | 4 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:37:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare] 37 | for (int j=0; j<v_temp.size(); ++j){ | ~^~~~~~~~~~~~~~ input/code.cpp:39:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare] 39 | if (j+1 < v_temp.size()){ | ~~~~^~~~~~~~~~~~~~~
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define f first #define s second #define PB push_back vector<pair<int, int>> v[606060]; int max_cnt[606060], max_ind[606060], num_cnt[606060]; map<int, int> m[606060]; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, q; cin >> n >> q; int M=1; while (M <= n) M*=2; for (int i=0; i<n; ++i) { int x; cin >> x; v[M+i].push_back({x,1}); max_cnt[M+i] = 1; max_ind[M+i] = x; num_cnt[M+i] = 1; m[M+i][x] = 1; } for (int i=M-1; i>=1; --i){ vector<pair<int, int>> v_temp; for (auto u:v[2*i]) v_temp.PB(u); for (auto u:v[2*i+1]) v_temp.PB(u); sort(v_temp.begin(), v_temp.end()); int ma_cnt = 0, ma_ind = 0; for (int j=0; j<v_temp.size(); ++j){ int f1 = v_temp[j].f, s1 = v_temp[j].s; if (j+1 < v_temp.size()){ int f2 = v_temp[j+1].f, s2 = v_temp[j+1].s; if (f1 == f2){ v[i].PB({f1, s1 + s2}); if (s1 + s2 > ma_cnt){ ma_cnt = s1 + s2; ma_ind = f1; } j++; } else v[i].PB({v_temp[j].f, v_temp[j].s}); } else v[i].PB({v_temp[j].f, v_temp[j].s}); } if (max_cnt[2*i] > ma_cnt){ // To control the interval, number must appear in both subintervals (above) // or interval is partly empty on the right side (this case). ma_cnt = max_cnt[2*i]; ma_ind = max_ind[2*i]; } num_cnt[i] = num_cnt[2*i]+ num_cnt[2*i+1]; if (ma_cnt*2 > num_cnt[i]){ max_cnt[i] = ma_cnt; max_ind[i] = ma_ind; } for (auto u:v[i]) m[i][u.f] = u.s; } /* for (int i=1; i<=2*M-1; ++i){ cout << "here " << i << " " << max_cnt[i] << " " << max_ind[i] << " " << num_cnt[i] << "\n"; for (auto u:v[i]) cout << u.f << " " << u.s << " " << m[i][u.f] << " "; cout << "\n"; } */ for (int i=1; i<=q; ++i){ int a, b; cin >> a >> b; int int_len = b-a+1; a+=M-1; b+=M-1; vector<int> interval_ind, candidates; while (b >= a){ if (a%2==1){ if (max_cnt[a]) candidates.PB(max_ind[a]); // We only add number to candidates if it controls at least one subinterval. interval_ind.PB(a); a++; } if (b%2==0){ if (max_cnt[b]) candidates.PB(max_ind[b]); interval_ind.PB(b); b--; } a/=2; b/=2; } sort(candidates.begin(), candidates.end()); // Let us test whether this part is fast enough for test 3. //int prev = 0; bool found = false; for (auto u:candidates){ //cout << "No, here! " << u << "\n"; //if (u == prev) continue; //prev = u; int num = 0; for (auto ite:interval_ind) num+=m[ite][u]; if (2*num > int_len){ cout << u << "\n"; found = true; //break; } } if (found == false) cout << "-1\n"; } }
Test details
Test 1
Group: 1, 2, 3, 4
Verdict: WRONG ANSWER
input |
---|
100 100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... |
Test 2
Group: 1, 2, 3, 4
Verdict: WRONG ANSWER
input |
---|
100 100 2 1 2 2 1 2 2 2 1 2 2 1 1 1 1 ... |
correct output |
---|
2 1 1 2 1 ... |
user output |
---|
2 2 2 2 1 ... |
Test 3
Group: 1, 3, 4
Verdict: ACCEPTED
input |
---|
100 100 5 19 44 88 14 79 50 44 14 99 7... |
correct output |
---|
-1 -1 -1 -1 -1 ... |
user output |
---|
-1 -1 -1 -1 -1 ... |
Test 4
Group: 2, 3, 4
Verdict: WRONG ANSWER
input |
---|
100000 100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... |
Test 5
Group: 2, 3, 4
Verdict: WRONG ANSWER
input |
---|
100000 100000 1 1 1 2 1 2 1 1 2 1 1 1 1 2 2 ... |
correct output |
---|
1 1 2 1 1 ... |
user output |
---|
1 1 1 1 1 ... |
Test 6
Group: 2, 3, 4
Verdict: WRONG ANSWER
input |
---|
100000 100000 8 2 6 1 10 4 9 7 8 10 4 2 8 2 ... |
correct output |
---|
-1 -1 -1 -1 -1 ... |
user output |
---|
-1 -1 -1 -1 -1 ... |
Test 7
Group: 3, 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 100000 141307 493258596 365539511 222... |
correct output |
---|
-1 -1 -1 -1 -1 ... |
user output |
---|
(empty) |
Test 8
Group: 4
Verdict: WRONG ANSWER
input |
---|
200000 200000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... |
Test 9
Group: 4
Verdict: WRONG ANSWER
input |
---|
200000 200000 1 2 2 2 1 2 2 1 1 1 1 1 1 1 1 ... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
2 2 2 2 2 ... |
Test 10
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 286470749 280175209 741317063 ... |
correct output |
---|
-1 -1 -1 -1 -1 ... |
user output |
---|
(empty) |
Test 11
Group: 3, 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 100000 613084013 1000000000 411999902... |
correct output |
---|
-1 -1 -1 -1 1000000000 ... |
user output |
---|
(empty) |
Test 12
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 613084013 1000000000 411999902... |
correct output |
---|
1000000000 1000000000 -1 1000000000 -1 ... |
user output |
---|
(empty) |
Test 13
Group: 3, 4
Verdict: WRONG ANSWER
input |
---|
100000 100000 663307073 663307073 663307073 ... |
correct output |
---|
329574367 965067805 768744535 691214891 21873594 ... |
user output |
---|
329574367 329574367 329574367 329574367 329574367 ... |
Test 14
Group: 4
Verdict: WRONG ANSWER
input |
---|
200000 200000 663307073 663307073 663307073 ... |
correct output |
---|
107596959 249558965 679275202 760593154 725418770 ... |
user output |
---|
107596959 107596959 107596959 107596959 249558965 ... |
Test 15
Group: 4
Verdict: WRONG ANSWER
input |
---|
200000 200000 663307073 663307073 663307073 ... |
correct output |
---|
211070558 49212342 651109313 264549124 651109313 ... |
user output |
---|
211070558 211070558 211070558 211070558 211070558 ... |
Test 16
Group: 4
Verdict: WRONG ANSWER
input |
---|
200000 200000 2 2 2 1 2 1 1 2 2 1 1 1 1 2 1 ... |
correct output |
---|
1 2 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... |