답안 #111103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111103 2019-05-13T16:33:36 Z CodeKracker Detecting Molecules (IOI16_molecules) C++14
0 / 100
3 ms 384 KB
/*input
14 14
2
13 15
*/
/**
    Author: Kristopher Paul
    Date Created: 13-05-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
//#define ll long long
//#define int ll
#define pb push_back
#define INF 0x3f3f3f3f //0x3f3f3f3f = 63
#define MOD 1000000007
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
/*
int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}*/

vector<int> find_subset(int l,int u,vector<int> w){
    int al,ar,len;
    al = ar = -1;
    len = -1;
    vector<pii> vec;
    FOR(i,0,w.size()){
        vec.pb({w[i],i});
    }
    sort(vec.begin(),vec.end());
    int i = 0,j = 0;
    bool vis[w.size()] = {};
    int csum = 0;
    vector<int> ans;
    if(vec[0].first > u){
        return ans;
    }
    while(i < w.size() && j < w.size() && (csum > u || csum < l)){
        if(csum < l){
            csum += vec[j].first;
            j++;
        }else if(csum > u){
            csum -= vec[i].first;
            i++;
        }
    }
    if(csum > u || csum < l){
        return ans;
    }
    FOR(k,i,j+1){
        ans.pb(vec[k].second);
    }
    return ans;
}
/*
void solve(){
    vector<int> tst;
    int l,u;
    cin >> l >> u;
    int n;
    cin >> n;
    FOR(i,0,n){
        int x;
        cin >> x;
        tst.pb(x);
    }
    vector<int> ans = find_subset(l,u,tst);
    FOR(i,0,ans.size()){
        cout << ans[i] << " ";
    }
    cout << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}
*/

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:25:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FOR(i,a,b) for (int i = a; i < b; i++)
molecules.cpp:65:9:
     FOR(i,0,w.size()){
         ~~~~~~~~~~~~                  
molecules.cpp:65:5: note: in expansion of macro 'FOR'
     FOR(i,0,w.size()){
     ^~~
molecules.cpp:76:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(i < w.size() && j < w.size() && (csum > u || csum < l)){
           ~~^~~~~~~~~~
molecules.cpp:76:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(i < w.size() && j < w.size() && (csum > u || csum < l)){
                           ~~^~~~~~~~~~
molecules.cpp:61:9: warning: variable 'al' set but not used [-Wunused-but-set-variable]
     int al,ar,len;
         ^~
molecules.cpp:61:15: warning: variable 'len' set but not used [-Wunused-but-set-variable]
     int al,ar,len;
               ^~~
molecules.cpp:70:10: warning: unused variable 'vis' [-Wunused-variable]
     bool vis[w.size()] = {};
          ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Integer 2 violates the range [0, 1]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB sum of weights should be in [302..304] but it is 353
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Integer 2 violates the range [0, 1]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Integer 2 violates the range [0, 1]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Integer 2 violates the range [0, 1]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Integer 2 violates the range [0, 1]
4 Halted 0 ms 0 KB -