#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e6;
vector<int>mn,mx;
vector<short>color;
ll st[4 * N];
void build(int l, int r, int node){
if(l == r){
st[node] = 1<<color[l];
return;
}
int mid = (l + r) >> 1;
build(l, mid, 2 * node + 1);
build(mid + 1, r, 2 * node + 2);
st[node] = st[2 * node + 1] | st[2 * node + 2];
}
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, 2 * node + 1) | query(ql, qr, mid + 1, r, 2 * node + 2);
}
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;
}
}
mn.push_back(curmn);
mx.push_back(curmx);
color.push_back(curc);
int n = (int)color.size();
build(0, n - 1, 0);
int r = 2;
for(int i = 0; i + 2 < n; i++){
if(__builtin_popcount(query(i, n - 1, 0, n - 1, 0)) < 3)break;
while(__builtin_popcount(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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Oczekiwano NIE |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Oczekiwano NIE |
2 |
Incorrect |
10 ms |
932 KB |
Expected integer, but "NIE" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Oczekiwano NIE |
2 |
Incorrect |
13 ms |
1232 KB |
Expected integer, but "NIE" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
468 KB |
Oczekiwano NIE |
2 |
Incorrect |
33 ms |
2100 KB |
Expected integer, but "NIE" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
852 KB |
Oczekiwano NIE |
2 |
Incorrect |
51 ms |
3740 KB |
Expected integer, but "NIE" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1972 KB |
Oczekiwano NIE |
2 |
Incorrect |
90 ms |
6736 KB |
Expected integer, but "NIE" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
207 ms |
24468 KB |
Output is correct |
2 |
Incorrect |
110 ms |
6944 KB |
Expected integer, but "NIE" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
202 ms |
24584 KB |
Output is correct |
2 |
Incorrect |
124 ms |
6896 KB |
Expected integer, but "NIE" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
402 ms |
47888 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
394 ms |
48868 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |