Submission #942496

#TimeUsernameProblemLanguageResultExecution timeMemory
942496attkyDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int * find_subset(int l, int u, int * w) { int n = sizeof(w) / sizeof(int); sort(w, w + n); for(int loop = 1; loop <= n; ++loop) { if(l <= w[0]*loop && w[0]*loop <= u) { int tab[loop]; for(int looping = 0; looping < loop; ++looping) { tab[looping] = w[0]; } return tab; } } int t[0]; return t; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, l, u; cin >> n >> l >> u; int w[n]; for(int loop = 0; loop < n; ++loop) { cin >> w[loop]; } int* sortie = find_subset(l, u, w); int m = sizeof(sortie) / sizeof(int); for(int loop = 0; loop < m; ++loop) { cout << sortie[loop]; } }

Compilation message (stderr)

molecules.cpp: In function 'int* find_subset(int, int, int*)':
molecules.cpp:6:20: warning: division 'sizeof (int*) / sizeof (int)' does not compute the number of array elements [-Wsizeof-pointer-div]
    6 |  int n = sizeof(w) / sizeof(int);
      |          ~~~~~~~~~~^~~~~~~~~~~~~
molecules.cpp:5:39: note: first 'sizeof' operand was declared here
    5 | int * find_subset(int l, int u, int * w) {
      |                                 ~~~~~~^
molecules.cpp:14:11: warning: address of local variable 'tab' returned [-Wreturn-local-addr]
   14 |    return tab;
      |           ^~~
molecules.cpp:10:8: note: declared here
   10 |    int tab[loop];
      |        ^~~
molecules.cpp:18:9: warning: address of local variable 't' returned [-Wreturn-local-addr]
   18 |  return t;
      |         ^
molecules.cpp:17:6: note: declared here
   17 |  int t[0];
      |      ^
molecules.cpp: In function 'int main()':
molecules.cpp:32:28: warning: division 'sizeof (int*) / sizeof (int)' does not compute the number of array elements [-Wsizeof-pointer-div]
   32 |     int m = sizeof(sortie) / sizeof(int);
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
molecules.cpp:31:10: note: first 'sizeof' operand was declared here
   31 |     int* sortie = find_subset(l, u, w);
      |          ^~~~~~
/usr/bin/ld: /tmp/ccNifpw0.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccHGqLW0.o:molecules.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccNifpw0.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