Submission #942021

#TimeUsernameProblemLanguageResultExecution timeMemory
942021hlk28khuongDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <cstdio> #include <vector> #include <cassert> #include "molecules.h" #include <bits/stdc++.h> using namespace std; #define int long long #define isz(a) ((int)(a.size())) typedef pair<int,int>ii; vector<int> find_subset(int l, int u, vector<int> w) { int n=isz(w); vector<ii>tmp; for(int i=0;i<n;i++) tmp.push_back(ii(w[i],i)); sort(tmp.begin(),tmp.end()); vector<int>res; int L=0; int sum=0; for(int i=0LL;i<isz(tmp);i++) { sum+=tmp[i].first; while(sum>u&&L<=i) { sum-=tmp[L].first; L++; } if(sum>=l&&sum<=u) { for(int j=L;j<=i;j++) res.push_back(tmp[j].second); sort(res.begin(),res.end()); break; } } return res; } int main() { int n, l, u; assert(3 == scanf("%d %d %d", &n, &l, &u)); std::vector<int> w(n); for (int i = 0; i < n; i++) assert(1 == scanf("%d", &w[i])); std::vector<int> result = find_subset(l, u, w); printf("%d\n", (int)result.size()); for (int i = 0; i < (int)result.size(); i++) printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]); }

Compilation message (stderr)

cc1plus: error: '::main' must return 'int'
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from molecules.cpp:7:
molecules.cpp: In function 'int main()':
molecules.cpp:42:23: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   42 |     assert(3 == scanf("%d %d %d", &n, &l, &u));
      |                       ^~~~~~~~~~  ~~
      |                                   |
      |                                   long long int*
molecules.cpp:42:25: note: format string is defined here
   42 |     assert(3 == scanf("%d %d %d", &n, &l, &u));
      |                        ~^
      |                         |
      |                         int*
      |                        %lld
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from molecules.cpp:7:
molecules.cpp:42:23: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   42 |     assert(3 == scanf("%d %d %d", &n, &l, &u));
      |                       ^~~~~~~~~~      ~~
      |                                       |
      |                                       long long int*
molecules.cpp:42:28: note: format string is defined here
   42 |     assert(3 == scanf("%d %d %d", &n, &l, &u));
      |                           ~^
      |                            |
      |                            int*
      |                           %lld
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from molecules.cpp:7:
molecules.cpp:42:23: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   42 |     assert(3 == scanf("%d %d %d", &n, &l, &u));
      |                       ^~~~~~~~~~          ~~
      |                                           |
      |                                           long long int*
molecules.cpp:42:31: note: format string is defined here
   42 |     assert(3 == scanf("%d %d %d", &n, &l, &u));
      |                              ~^
      |                               |
      |                               int*
      |                              %lld
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from molecules.cpp:7:
molecules.cpp:45:27: warning: format '%d' expects argument of type 'int*', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type*' {aka 'long long int*'} [-Wformat=]
   45 |         assert(1 == scanf("%d", &w[i]));
      |                           ^~~~
molecules.cpp:45:29: note: format string is defined here
   45 |         assert(1 == scanf("%d", &w[i]));
      |                            ~^
      |                             |
      |                             int*
      |                            %lld
molecules.cpp:49:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   49 |     printf("%d\n", (int)result.size());
      |             ~^     ~~~~~~~~~~~~~~~~~~
      |              |     |
      |              int   long long int
      |             %lld
molecules.cpp:51:18: warning: format '%d' expects argument of type 'int', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} [-Wformat=]
   51 |         printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]);
      |                 ~^
      |                  |
      |                  int
      |                 %lld