| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1361490 | jalol250 | 3개의 봉우리 (IOI25_triples) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
// ---------------- PART I ----------------
long long count_triples(vector<int> &H){
int n = H.size();
long long ans = 0;
for(int i = 0; i < n; i++){
for(int j = i + 1; j < n; j++){
for(int k = j + 1; k < n; k++){
int a = H[i], b = H[j], c = H[k];
int x = j - i, y = k - j, z = k - i;
if( (a==x && b==y && c==z) ||
(a==x && b==z && c==y) ||
(a==y && b==x && c==z) ||
(a==y && b==z && c==x) ||
(a==z && b==x && c==y) ||
(a==z && b==y && c==x) ){
ans++;
}
}
}
}
return ans;
}
// ---------------- PART II ----------------
vector<int> construct_range(int M, int K){
int n = M;
if(n > 1000) n = 1000;
if(n < 3) n = 3;
vector<int> H(n);
for(int i = 0; i < n; i++){
H[i] = i + 1;
}
return H;
}
// ---------------- MAIN ----------------
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int type;
cin >> type;
if(type == 1){
// Part I
int n;
cin >> n;
vector<int> H(n);
for(int i = 0; i < n; i++) cin >> H[i];
cout << count_triples(H);
}
else{
// Part II
int M, K;
cin >> M >> K;
vector<int> H = construct_range(M, K);
cout << H.size() << '\n';
for(int x : H) cout << x << ' ';
}
}