제출 #1325517

#제출 시각아이디문제언어결과실행 시간메모리
1325517iamsazidhDetecting Molecules (IOI16_molecules)C++20
100 / 100
35 ms4508 KiB
#include "molecules.h"
//ᴇᴀᴄʜ ᴘᴇʀꜱᴏɴ ᴡɪʟʟ ᴏɴʟʏ ʜᴀᴠᴇ ᴡʜᴀᴛ ᴛʜᴇʏ ᴇɴᴅᴇᴀᴠᴏᴜʀᴇᴅ ᴛᴏᴡᴀʀᴅꜱ [53:39]
//Author: Sazid Hasan
#include <bits/stdc++.h>
using namespace std;

typedef long long              ll;
typedef double                 dl;
typedef vector<int>            vi;
typedef vector<vector<int>>    vii;
typedef vector<ll>             vl;
typedef vector<bool>           vb;
typedef pair<int,int>         pii;
typedef pair<ll, ll>          pll;

#define ff                first
#define ss                second
#define all(a)            a.begin(),a.end()
#define gcd(a,b)          __gcd(a,b)
#define lcm(a,b)          (a*(b/gcd(a,b)))
#define spc               " "

#ifdef ONLINE_JUDGE
    #define debarr(array)
    #define deb(x)
    #define del
#else
    #define debarr(array)  for(int w = 0; w < array.size(); w++) cerr << #array << "-" << w << " = " << array[w] << endl;
    #define deb(x)         cerr << #x << " = " << x << endl;
    #define del cerr << '\n';
#endif


const double PI =         acos(-1);
const int MOD =           1000000007;
const int inf =           (2147483647);

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    int n = w.size();
    vector<pii> arr(n);
    for(int i = 0; i < n; i++) arr[i] = {w[i], i};
    sort(all(arr));
    int f = 0, r = 0;
    ll sm = 0;
    for(r = 0; r < n; r++){
        sm += arr[r].ff;
        while(f<=r && sm>u) sm -= arr[f++].ff;
        if(sm>=l && sm<=u) break;
    }
    if(r==n) return {};
    vi ans;
    for(int i = f; i <= r; i++) ans.push_back(arr[i].ss);
    vi p = w;
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...