# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
799406 |
2023-07-31T13:55:24 Z |
BidoTeima |
Sticks (POI11_pat) |
C++17 |
|
364 ms |
28456 KB |
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e6;
int mn[N],mx[N];
uint8_t color[N];
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;
pair<int,uint8_t> arr[N];
int cur=0;
int tot=0;
for(int i = 0; i < k; i++){
int n;
cin>>n;
tot+=n;
for(int j = 0; j < n; j++){
int w;
cin>>w;
arr[cur].first=w,arr[cur].second=i;
++cur;
}
}
sort(arr, arr+tot);
cur=0;
int curmn=arr[0].first,curmx=arr[0].first,curc=arr[0].second;
for(int i = 1; i < tot; i++){
if(arr[i].second != arr[i - 1].second){
mn[cur]=curmn;
mx[cur]=curmx;
color[cur]=curc;
curmn=curmx=arr[i].first,curc=arr[i].second;
++cur;
}else{
curmx=arr[i].first;
}
}
mn[cur]=curmn,mx[cur]=curmx,color[cur]=curc;
++cur;
int n = cur;
build(0, n - 1, 0);
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 |
4 ms |
8148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8148 KB |
Output is correct |
2 |
Correct |
3 ms |
8148 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8148 KB |
Oczekiwano NIE |
2 |
Correct |
12 ms |
8124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8148 KB |
Oczekiwano NIE |
2 |
Correct |
15 ms |
8132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8148 KB |
Oczekiwano NIE |
2 |
Correct |
33 ms |
8124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
8124 KB |
Oczekiwano NIE |
2 |
Correct |
54 ms |
8196 KB |
Output is correct |
3 |
Correct |
39 ms |
8488 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
8128 KB |
Oczekiwano NIE |
2 |
Correct |
86 ms |
8140 KB |
Output is correct |
3 |
Correct |
65 ms |
8900 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
188 ms |
17712 KB |
Output is correct |
2 |
Correct |
128 ms |
8104 KB |
Output is correct |
3 |
Correct |
108 ms |
9260 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
197 ms |
18348 KB |
Output is correct |
2 |
Correct |
119 ms |
8108 KB |
Output is correct |
3 |
Correct |
128 ms |
9648 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
364 ms |
25328 KB |
Output is correct |
2 |
Correct |
135 ms |
11812 KB |
Output is correct |
3 |
Correct |
180 ms |
14112 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
357 ms |
28456 KB |
Output is correct |
2 |
Correct |
158 ms |
12428 KB |
Output is correct |
3 |
Correct |
270 ms |
15392 KB |
Oczekiwano NIE |