제출 #362124

#제출 시각아이디문제언어결과실행 시간메모리
362124EyedDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <algorithm> #include <vector> #include "molecules.h" typedef long long ll; typedef pair<ll, int> pii; using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { ll prefix[200005]; ll suffix[200005]; ll n = w.size(); vector<pii> nW; vector<int> ans; bool less = false; for (ll i = 0; i < n; ++i) { if (w[i] >= l && w[i] <= u) { ans.push_back(w[i]); return ans; } if (w[i] < l) less = true; nW.push_back(make_pair(w[i], i )); } if (!less) { return ans; } sort(nW.begin(), nW.end()); //for (ll i = 0; i < n; ++i) cout << w[i] << " "; //cout << endl; prefix[0] = nW[0]; suffix[n - 1] = nW[n - 1]; for (ll i = 1; i < n; ++i) prefix[i] = prefix[i - 1] + nW[i].first; for (ll i = n - 2; i >= 0; --i) suffix[i] = suffix[i + 1] + nW[i].first; if (prefix[n - 1] < l) { return ans; } for (ll i = 0; i < n; ++i) { if (prefix[i] >= l && prefix[i] <= u) { for (ll j = 0; j <= i; ++j) ans.push_back(nW[j].second); return ans; } if (suffix[n - i - 1] >= l && suffix[n - i - 1] <= u) { for (ll j = n - 1; j >= n - i - 1; --j) ans.push_back(nW[j].second); return ans; } if (!(prefix[i] < l && suffix[n - i - 1] > u)) continue; ll curSum = prefix[i]; for (ll j = 0; j <= min(i, n - i - 1); ++j) { curSum += (nW[n - j - 1] - nW[j]); if (curSum >= l && curSum <= u) { for (ll k = 0; k <= j; ++k) ans.push_back(nW[n - k - 1].second); for (ll k = j + 1; k <= i; ++k) ans.push_back(nW[k].second); return ans; } } return ans; } return ans; }

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

molecules.cpp:6:9: error: 'pair' does not name a type
    6 | typedef pair<ll, int> pii;
      |         ^~~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:9: error: 'pii' was not declared in this scope
   13 |  vector<pii> nW;
      |         ^~~
molecules.cpp:13:12: error: template argument 1 is invalid
   13 |  vector<pii> nW;
      |            ^
molecules.cpp:13:12: error: template argument 2 is invalid
molecules.cpp:22:6: error: request for member 'push_back' in 'nW', which is of non-class type 'int'
   22 |   nW.push_back(make_pair(w[i], i ));
      |      ^~~~~~~~~
molecules.cpp:27:10: error: request for member 'begin' in 'nW', which is of non-class type 'int'
   27 |  sort(nW.begin(), nW.end());
      |          ^~~~~
molecules.cpp:27:22: error: request for member 'end' in 'nW', which is of non-class type 'int'
   27 |  sort(nW.begin(), nW.end());
      |                      ^~~
molecules.cpp:30:18: error: invalid types 'int[int]' for array subscript
   30 |  prefix[0] = nW[0];
      |                  ^
molecules.cpp:31:26: error: invalid types 'int[ll {aka long long int}]' for array subscript
   31 |  suffix[n - 1] = nW[n - 1];
      |                          ^
molecules.cpp:32:61: error: invalid types 'int[ll {aka long long int}]' for array subscript
   32 |  for (ll i = 1; i < n; ++i) prefix[i] = prefix[i - 1] + nW[i].first;
      |                                                             ^
molecules.cpp:33:66: error: invalid types 'int[ll {aka long long int}]' for array subscript
   33 |  for (ll i = n - 2; i >= 0; --i) suffix[i] = suffix[i + 1] + nW[i].first;
      |                                                                  ^
molecules.cpp:39:50: error: invalid types 'int[ll {aka long long int}]' for array subscript
   39 |    for (ll j = 0; j <= i; ++j) ans.push_back(nW[j].second);
      |                                                  ^
molecules.cpp:43:62: error: invalid types 'int[ll {aka long long int}]' for array subscript
   43 |    for (ll j = n - 1; j >= n - i - 1; --j) ans.push_back(nW[j].second);
      |                                                              ^
molecules.cpp:49:27: error: invalid types 'int[ll {aka long long int}]' for array subscript
   49 |    curSum += (nW[n - j - 1] - nW[j]);
      |                           ^
molecules.cpp:49:35: error: invalid types 'int[ll {aka long long int}]' for array subscript
   49 |    curSum += (nW[n - j - 1] - nW[j]);
      |                                   ^
molecules.cpp:51:59: error: invalid types 'int[ll {aka long long int}]' for array subscript
   51 |     for (ll k = 0; k <= j; ++k) ans.push_back(nW[n - k - 1].second);
      |                                                           ^
molecules.cpp:52:55: error: invalid types 'int[ll {aka long long int}]' for array subscript
   52 |     for (ll k = j + 1; k <= i; ++k) ans.push_back(nW[k].second);
      |                                                       ^