답안 #793431

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
793431 2023-07-25T20:24:06 Z Antekb Broken Device (JOI17_broken_device) C++17
100 / 100
484 ms 2828 KB
#include<bits/stdc++.h>

#pragma GCC optimize("Ofast")
//#pragma GCC optimize("trapv")
 
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define pp(x) pop_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) (x).begin(), (x).end()
#define rev(x) reverse(all(x))
#define sor(x) sort(all(x))
#define sz(x) (int)(x).size()
#define rsz(x) resize(x)
 
using namespace std;
 
///~~~~~~~~~~~~~~~~~~~~~~~~~~
 
template <typename H, typename T> 
ostream& operator<<(ostream& os, pair<H, T> m){
	return os <<"("<< m.st<<", "<<m.nd<<")";
}
template <typename H> 
ostream& operator<<(ostream& os, vector<H> V){
	os<<"{";
	for(int i=0; i<V.size(); i++){
		if(i)os<<" ";
		os<<V[i];
	}
	os<<"}";
	return os;
}
 
void debug(){cerr<<"\n";}
template <typename H, typename... T>
void debug(H h, T... t) {cerr<<h; if (sizeof...(t)) cerr << ", "; debug(t...);}
#define deb(x...) cerr<<#x<<" = ";debug(x);
//#define deb(x...) ;
 
///~~~~~~~~~~~~~~~~~~~~~~~~~
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef string str;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

 
#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
#include "Annalib.h"

void Anna(int n, long long X, int K, int P[] ){
	assert(n==150);
	srand(24636346);
	vi kol(n), co(n);
	iota(all(kol), 0);
	random_shuffle(all(kol));
	vi val(n);
	int blo=5;
	int pot=4000;
	for(int i=0; i<n; i++){
		val[i]=rand()%pot;
		co[kol[i]]=i;
	}
	for(int i=0; i<K; i++){
		//deb(kol[P[i]]);
		val[kol[P[i]]]=0;
	}
	vi ans(n);
	for(int i=0; i<blo; i++){
		//deb(i);
		int reszta=X%pot;
		X/=pot;
		vi tim(pot, 1e9);
		tim[0]=-1;
		for(int j=i*n/blo; j<(i+1)*n/blo; j++){
			int t=val[j];
			//deb(t, j);
			for(int k=t; k<pot; k++){
				if(tim[k]==1e9 && tim[k-t]<j)tim[k]=j;
			}
			for(int k=0; k<t; k++){
				if(tim[k]==1e9 && tim[k+pot-t]<j)tim[k]=j;
			}
			if(tim[reszta]!=1e9){
				//deb("a");
				break;
			}
		}
		assert(tim[reszta]!=1e9);
		while(reszta){
			//deb(reszta);
			ans[co[tim[reszta]]]=1;
			int t=val[tim[reszta]];
			//deb(t);
			reszta=(reszta+pot-t)%pot;
		}
	}
	for( int i = 0; i < n; i++ ){
		Set( i, ans[i] );
	}
}
#include<bits/stdc++.h>

#pragma GCC optimize("Ofast")
//#pragma GCC optimize("trapv")
 
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define pp(x) pop_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) (x).begin(), (x).end()
#define rev(x) reverse(all(x))
#define sor(x) sort(all(x))
#define sz(x) (int)(x).size()
#define rsz(x) resize(x)
 
using namespace std;
 
///~~~~~~~~~~~~~~~~~~~~~~~~~
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef string str;

#include "Brunolib.h"

long long Bruno( int n, int A[] ){
	srand(24636346);
	vi kol(n), co(n);
	iota(all(kol), 0);
	random_shuffle(all(kol));
	vi val(n);
	int blo=5;
	int pot=4000;
	for(int i=0; i<n; i++){
		val[i]=rand()%pot;
		co[kol[i]]=i;
	}
	ll ans=0;
	for(int i=blo-1; i>=0; i--){
		ans*=pot;
		int reszta=0;
		for(int j=i*n/blo; j<(i+1)*n/blo; j++){
			if(A[co[j]]){
				//cerr<<val[j]<<"\n";
				reszta+=val[j];
			}
		}
		//cerr<<reszta%pot<<"\n";
		ans+=reszta%pot;
		//cerr<<ans<<"\n";
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 443 ms 2428 KB Output is correct - L* = 40
2 Correct 448 ms 2580 KB Output is correct - L* = 40
3 Correct 445 ms 2472 KB Output is correct - L* = 40
4 Correct 427 ms 2452 KB Output is correct - L* = 40
5 Correct 434 ms 2468 KB Output is correct - L* = 40
6 Correct 430 ms 2484 KB Output is correct - L* = 40
7 Correct 435 ms 2592 KB Output is correct - L* = 40
8 Correct 462 ms 2600 KB Output is correct - L* = 40
9 Correct 440 ms 2488 KB Output is correct - L* = 40
10 Correct 441 ms 2548 KB Output is correct - L* = 40
11 Correct 433 ms 2468 KB Output is correct - L* = 40
12 Correct 437 ms 2488 KB Output is correct - L* = 40
13 Correct 437 ms 2440 KB Output is correct - L* = 40
14 Correct 440 ms 2772 KB Output is correct - L* = 40
15 Correct 423 ms 2444 KB Output is correct - L* = 40
16 Correct 444 ms 2448 KB Output is correct - L* = 40
17 Correct 430 ms 2588 KB Output is correct - L* = 40
18 Correct 425 ms 2424 KB Output is correct - L* = 40
19 Correct 431 ms 2436 KB Output is correct - L* = 40
20 Correct 431 ms 2520 KB Output is correct - L* = 40
21 Correct 484 ms 2552 KB Output is correct - L* = 40
22 Correct 430 ms 2640 KB Output is correct - L* = 40
23 Correct 433 ms 2504 KB Output is correct - L* = 40
24 Correct 433 ms 2656 KB Output is correct - L* = 40
25 Correct 438 ms 2520 KB Output is correct - L* = 40
26 Correct 476 ms 2580 KB Output is correct - L* = 40
27 Correct 428 ms 2460 KB Output is correct - L* = 40
28 Correct 443 ms 2612 KB Output is correct - L* = 40
29 Correct 437 ms 2688 KB Output is correct - L* = 40
30 Correct 434 ms 2408 KB Output is correct - L* = 40
31 Correct 452 ms 2408 KB Output is correct - L* = 40
32 Correct 436 ms 2560 KB Output is correct - L* = 40
33 Correct 456 ms 2492 KB Output is correct - L* = 40
34 Correct 439 ms 2460 KB Output is correct - L* = 40
35 Correct 436 ms 2424 KB Output is correct - L* = 40
36 Correct 436 ms 2828 KB Output is correct - L* = 40
37 Correct 454 ms 2580 KB Output is correct - L* = 40
38 Correct 434 ms 2468 KB Output is correct - L* = 40
39 Correct 464 ms 2464 KB Output is correct - L* = 40
40 Correct 457 ms 2568 KB Output is correct - L* = 40