제출 #1261537

#제출 시각아이디문제언어결과실행 시간메모리
1261537am_aadvik3개의 봉우리 (IOI25_triples)C++20
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include <set> using namespace std; bool check(int i, int j, int k, vector<int>& a) { vector<int> x = { j - i, k - i, k - j }; vector<int> y = { a[i], a[j], a[k] }; sort(x.begin(), x.end()); sort(y.begin(), y.end()); for (int i = 0; i < 3; ++i) if (x[i] != y[i]) return 0; return 1; } int find(int i, int k, vector<int>&a) { if ((k < 0) || ((k >= a.size()))) return 0; if ((i < 0) || ((i >= a.size()))) return 0; vector<int> op = { i + a[i], k - a[i], i + a[k], k - a[k] }; set<int> s; for (auto x : op) s.insert(x); int ans = 0; for (auto j : s) if((j >= 0) && (j < a.size())) ans += (check(i, j, k, a)); return ans; } long long count_triples(vector<int> a) { long long n = a.size(), ans = 0; for (int x = 0; x < n; ++x) for (auto y : { x - a[x], x + a[x]}) if (!((y < 0) || ((y >= a.size())))) { set<int> s; for (auto v : { x - a[x], x + a[x], y + a[y], y - a[y], y + a[x], y - a[x], x + a[y], x - a[y] }) s.insert(v); for (auto z : s) { if ((z < 0) || ((z >= a.size()))) continue; vector<int> op = { x, y, z }; sort(op.begin(), op.end()); int best = 0; bool ok = 1; for (int i = 0; i < 3; ++i) for (auto q : { op[i] + a[op[i]], op[i] - a[op[i]] }) if ((q == op[0]) || (q == op[1]) || (q == op[2])) best = op[i]; if (best == x) if (check(op[0], op[1], op[2], a)) ++ans; } } return ans; } vector<int> construct_range(int M, int K) { vector<int> a = { 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }; return a; } int main() { cout << count_triples({ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }); }

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccW6g0Q0.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cca3E1sf.o:triples.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status