제출 #49477

#제출 시각아이디문제언어결과실행 시간메모리
49477Mamnoon_SiamDetecting Molecules (IOI16_molecules)C++17
31 / 100
1088 ms25980 KiB
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define MEMSET(a,val) memset(a, val, sizeof a)
#define PB push_back
#define endl '\n'

inline int myrand(int l, int r) {
	int ret = rand(); ret <<= 15; ret ^= rand();
	if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
	return ret;
}
template <typename F, typename S>
ostream& operator << (ostream& os, const pair< F, S>& p) {
    return os<<"(" <<p.first<<", "<<p.second<<")"; }

typedef pair<int, int> ii;
template<typename T> using min_pq =
	priority_queue<T, vector<T>, greater<T> >;

//int dx[] = {-1, +0, +1, +0};
//int dy[] = {+0, +1, +0, -1};

const int maxn = 10005;

bitset<maxn> dp[maxn], vis[maxn];
int a[maxn], l, n, u;

int get(int i, int v) {
	if(l <= v and v <= u) return 1;
	if(v > u or i == n) return 0;
	if(vis[i][v]) return dp[i][v];
	vis[i][v] = 1;
	dp[i][v] = get(i + 1, v) | get(i + 1, v + a[i]);
	return dp[i][v];
}

void fill(int i, int v, vector<int> &ret) {
	if(l <= v and v <= u) {
		return;
	}
	assert(i < n);
	if(get(i + 1, v)) {
		fill(i + 1, v, ret);
	} else {
		ret.push_back(i);
		fill(i + 1, v + a[i], ret);
	}
}

vector<int> find_subset(int L, int U, vector<int> w) {
    n = w.size(), l = L, u = U;
    for(int i=0; i<n; i++)
    	a[i] = w[i];
    MEMSET(dp, -1);
    if(get(0, 0)) {
    	vector<int> ret;
    	fill(0, 0, ret);
    	return ret;
    }
    else {
    	return vector<int>();
    }
}

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

molecules.cpp: In function 'int myrand(int, int)':
molecules.cpp:17:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
  ^~
molecules.cpp:17:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
                          ^~~
#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...