# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
799398 |
2023-07-31T13:49:10 Z |
BidoTeima |
Sticks (POI11_pat) |
C++17 |
|
378 ms |
35772 KB |
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e6 + 3;
vector<int>mn,mx;
vector<short>color;
ll st[2 * N];
void build(int l, int r, int node){
if(l == r){
st[node] = 1ll<<color[l];
return;
}
int mid = (l + r) >> 1;
build(l, mid, node + 1);
build(mid + 1, r, node + 2 * (mid - l + 1));
st[node] = st[node + 1] | st[node + 2 * (mid - l + 1)];
}
ll query(int ql, int qr, int l, int r, int node){
if(l > qr || r < ql)
return 0;
if(ql <= l && r <= qr){
return st[node];
}
int mid = (l + r) >> 1;
return query(ql, qr, l, mid, node + 1) | query(ql, qr, mid + 1, r, node + 2 * (mid - l + 1));
}
int main() {
int k;
cin>>k;
vector<pair<int,short>>arr;
for(int i = 0; i < k; i++){
int n;
cin>>n;
for(int j = 0; j < n; j++){
int w;
cin>>w;
arr.push_back(make_pair(w, i));
}
}
sort(arr.begin(), arr.end());
int curmn=arr[0].first,curmx=arr[0].first,curc=arr[0].second;
for(int i = 1; i < (int)arr.size(); i++){
if(arr[i].second != arr[i - 1].second){
mn.push_back(curmn);
mx.push_back(curmx);
color.push_back(curc);
curmn=curmx=arr[i].first,curc=arr[i].second;
}else{
curmx=arr[i].first;
}
}
mn.push_back(curmn);
mx.push_back(curmx);
color.push_back(curc);
int n = (int)color.size();
build(0, n - 1, 0);
arr.clear();
int r = 2;
for(int i = 0; i + 2 < n; i++){
if(__builtin_popcountll(query(i, n - 1, 0, n - 1, 0)) < 3)break;
while(__builtin_popcountll(query(i, r, 0, n - 1, 0)) < 3){
r++;
}
//i,i+1,r
if(mx[i]+mx[i+1]>mn[r]){
return cout<<color[i]+1<<' '<<mx[i]<<' '<<color[i+1]+1<<' '<<mx[i+1]<<' '<<color[r]+1<<' '<<mn[r], 0;
}
}
cout<<"NIE";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Oczekiwano NIE |
2 |
Correct |
9 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Oczekiwano NIE |
2 |
Correct |
13 ms |
848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Oczekiwano NIE |
2 |
Correct |
36 ms |
1500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
624 KB |
Oczekiwano NIE |
2 |
Correct |
49 ms |
2396 KB |
Output is correct |
3 |
Correct |
48 ms |
2520 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
1468 KB |
Oczekiwano NIE |
2 |
Correct |
84 ms |
4440 KB |
Output is correct |
3 |
Correct |
59 ms |
3684 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
17524 KB |
Output is correct |
2 |
Correct |
104 ms |
4508 KB |
Output is correct |
3 |
Correct |
94 ms |
5688 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
209 ms |
18204 KB |
Output is correct |
2 |
Correct |
114 ms |
4528 KB |
Output is correct |
3 |
Correct |
122 ms |
7072 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
368 ms |
32844 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
378 ms |
35772 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |