Submission #972317

# Submission time Handle Problem Language Result Execution time Memory
972317 2024-04-30T10:49:46 Z Tanos Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define el "\n"
#define pb push_back
#define pp pop_back
#define pii pair <int, int>
#define pll pair <ll, ll>
#define ibase ios_base::sync_with_stdio(0), cin.tie(0);

const int N = 5e5 + 5, M = 1e3 + 5, pw = 31;
const ll MAX = 1e15, inf = 1e9 + 7;

vector <int> find_subset(int l, int u, int a[]) {
	int n = sizeof a;
	pair <int, int> p[n];
	for (int i = 0; i <= n; i++) {
		p[i] = {a[i], i + 1};
	}
	ll sum = 0, j = 0, last = 0;
	for (int i = 0; i < n; i++) {
		sum += p[i].x;
		last = i;
		if (sum >= l && sum <= u) {
			break;
		}
		else if (sum >= l) {
			int j = 0;
			while (sum > u)
				sum -= p[j++].x;
			break;
		}
	}
	vector <int> ans;
	for (int i = j; i <= last; i++)
		ans.pb(i);
	return ans;
}



//void solve() {
//	
//	
//}

//int main() {
//    ibase;
//    int T = 1;
////    cin >> T;
//    for (int test = 1; test <= T; ++test) {
////        cout << " " << test << ":" << el;
//        solve();
//        cout << el;
//    }
//}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, int*)':
molecules.cpp:20:17: warning: 'sizeof' on array function parameter 'a' will return size of 'int*' [-Wsizeof-array-argument]
   20 |  int n = sizeof a;
      |                 ^
molecules.cpp:19:44: note: declared here
   19 | vector <int> find_subset(int l, int u, int a[]) {
      |                                        ~~~~^~~
/usr/bin/ld: /tmp/ccdn7Vnx.o: in function `main':
grader.cpp:(.text.startup+0x18d): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status