답안 #320978

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320978 2020-11-10T11:57:33 Z neki Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 1010
#define pa pair<ll, ll>
#define ld long double 

vc<int> find_subset(int l, int u, vc<int> w){
    vc<pa> ar;
    loop(i, 0, w.size()){
        ll v=w[i];
        if(v<l)ar.ps(make_pair(v, i));
        else if(v<=u) return vc<int> {i};
    }
    if(ar.size()==0) return vc<int> {};
    sort(all(ar));
    ll n=ar.size();
    vc<ll> sum(n+1, 0);
    loop(i, 0, n) sum[i+1]=sum[i]+ar[i].fi;
    loop(i, 1, n+1) if(sum[i]-sum[0]<=u and l<=sum[n]-sum[n-i]){
        loop(j, 0, n-i+1) if(l<=sum[j+i]-sum[j] and sum[j+i]-sum[j]<=u){
            vc<int> ans;
            loop(z, j+1, j+1+i) ans.ps(ar[z].se);
            sort(all(ans));
            return ans;
        }
    }
    return vc<int> {};
}
int main(){
    fore(v, find_subset(15, 17, {6, 8, 8, 7})) cout << v <<" ";cout<<endl;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:3:42: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define loop(i, a, b) for(long long i=a;i<b;i++)
......
   26 |     loop(i, 0, w.size()){
      |          ~~~~~~~~~~~~~~                   
molecules.cpp:26:5: note: in expansion of macro 'loop'
   26 |     loop(i, 0, w.size()){
      |     ^~~~
molecules.cpp:29:39: warning: narrowing conversion of 'i' from 'long long int' to 'int' [-Wnarrowing]
   29 |         else if(v<=u) return vc<int> {i};
      |                                       ^
molecules.cpp:29:39: warning: narrowing conversion of 'i' from 'long long int' to 'int' [-Wnarrowing]
molecules.cpp: In function 'int main()':
molecules.cpp:5:20: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    5 | #define fore(i, a) for(auto&& i:a)
      |                    ^~~
molecules.cpp:47:5: note: in expansion of macro 'fore'
   47 |     fore(v, find_subset(15, 17, {6, 8, 8, 7})) cout << v <<" ";cout<<endl;
      |     ^~~~
molecules.cpp:47:64: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   47 |     fore(v, find_subset(15, 17, {6, 8, 8, 7})) cout << v <<" ";cout<<endl;
      |                                                                ^~~~
/tmp/ccdp13Jp.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc4tvMYO.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status