답안 #186943

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
186943 2020-01-12T11:44:52 Z PedroBigMan Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 504 KB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include "molecules.h"
using namespace std;
typedef int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define INF 100000000000000000LL
ll insig;
#define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);}
void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}

vector<ll> find_subset(ll l,ll u, vector<ll> wee)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll N=wee.size(); vector<pl> we; 
    ll curin;
    REP(i,0,N) {we.pb(mp(wee[i],i));}
    sort(we.begin(),we.end()); vector<ll> w; REP(i,0,N) {w.pb(we[i].ff);}
    vector<bool> cur; REP(i,0,N) {cur.pb(false);}
    vector<pl> sums; ll losum=0; ll hisum=0;
    REP(i,0,N)
    {
        losum+=w[i]; hisum+=w[N-i-1];
        sums.pb(mp(losum,hisum));
    }
    vector<ll> ans;
    REP(k,1,N+1)
    {
        if(sums[k-1].ff<=u && sums[k-1].ss>=l)
        {
            ll curs=0;
            REP(i,0,k) {cur[i]=true; curs+=w[i];}
            ll ind=0;
            while(curs<l)
            {
                cur[ind]=false; cur[N-1-ind]=true;
                curs-=w[ind]; curs+=w[N-1-ind];
            }
            REP(i,0,N) {if(cur[i]) {ans.pb(we[i].ss+1);}}
            return ans;
        }
    }
    return ans;
}

Compilation message

molecules.cpp: In function 'void Out(std::vector<int>)':
molecules.cpp:15:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
molecules.cpp:24:29:
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                             ~~~~~~~~~~~~
molecules.cpp:24:25: note: in expansion of macro 'REP'
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                         ^~~
molecules.cpp: In function 'std::vector<int> find_subset(ll, ll, std::vector<int>)':
molecules.cpp:31:8: warning: unused variable 'curin' [-Wunused-variable]
     ll curin;
        ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 380 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Integer 12 violates the range [0, 11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 380 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 380 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 380 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB OK (n = 1, answer = NO)
2 Correct 2 ms 380 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -