답안 #793203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
793203 2023-07-25T15:45:13 Z Antekb Minerals (JOI19_minerals) C++17
40 / 100
45 ms 4376 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);
 
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const int K=17, N=1<<K, INF=1e9+5, mod2=1e9+7, mod=998244353;

struct modint{
	int n=0;
	modint(){}
	modint(ll x){
		n=x%mod;
		if(n<0)n+=mod;
	}
	operator int(){
		return n;
	}
	modint operator+(modint a){a.n = n+a.n; if(a.n>=mod)a.n-=mod;return a;}
	modint operator+=(modint a){return (*this)=(*this)+a;}
	modint operator-(modint a){a.n = n-a.n; if(a.n<0)a.n+=mod;return a;}
	modint operator-=(modint a){return (*this)=(*this)-a;}
	modint operator*(modint a){a.n = (n*1ll*a.n)%mod; return a;}
	modint operator*=(modint a){return (*this)=(*this)*a;}
	modint operator^(const ll &m)const{
		modint a(1);
		if(m==0)return a;
		if(m==1)return (*this);
		a=(*this)^(m/2);
		a*=a;
		return a*((*this)^(m&1));
	}
	modint odw(){
		return (*this)^((ll)mod-2);
	}
	modint operator/(modint a){return (*this)*a.odw();}
	modint operator/=(modint a){return (*this)=(*this)/a;}
	bool operator==(modint a){return a.n==n;}
	friend ostream& operator<<(ostream& os, modint m) {
		return os << m.n; 
	}
};
/*modint fact[N], fact2[N];
typedef vector<modint> vm;
void factinit(){
    fact[0]=1;
    for(int i=1; i<N; i++){
        fact[i]=(fact[i-1]*modint(i))%mod;
    }
    fact2[N-1]=fact[N-1].odw();
    for(int i=N-2; i>=0; i--){
    	fact2[i]=(fact2[i+1]*modint(i+1))%mod;
    }
}
modint npok(int _n, int _k){
 	if(_n<_k)return 0;
    return fact[_n]*fact2[_k]*fact2[_n-_k];
}*/
int los(int a, int b){
	return a+(rng())%(b-a+1);
}
#include "minerals.h"
/*vi wynik={0, 2, 0, 1, 4, 3, 2, 1, 3, 4};
int czy_w_srodku[N];
int ile_dobrze=0;
int stan[N];
int rozne=0;
int Query(int x){
	x--;
	czy_w_srodku[x]^=1;
	if(czy_w_srodku[x]){
		if(!stan[wynik[x]]++)rozne++;
	}
	else{	
		if(!--stan[wynik[x]])rozne--;
	}
	return rozne;
}
void Answer(int a, int b){
	deb(a, b, wynik[a-1], wynik[b-1]);
	assert(wynik[a-1]==wynik[b-1]);
	ile_dobrze++;
}*/
void solve(vi V){
	//deb(V);
	if(V.size()==0)return;
	if(V.size()==2){
		Answer(V[0], V[1]);
		return;
	}
	vi typ(V.size());
	vi V2(V.size());
	iota(all(V2), 0);
	shuffle(all(V2), rng);
	int akt=0;
	for(int i=0; i<V2.size(); i++){
		int now=Query(V[V2[i]]);
		if(now!=akt)typ[V2[i]]++;
		akt=now;
	}
	shuffle(all(V2), rng);
	for(int i=0; i<V.size(); i++){
		int now=Query(V[V2[i]]);
		if(now!=akt)typ[V2[i]]+=2;
		akt=now;
	}
	//deb(typ);
	vi L, R;
	for(int i=0; i<V.size(); i++){
		if(typ[i]%3)L.pb(V[i]);
		else R.pb(V[i]);
	}
	solve(L);
	solve(R);
}
void Solve(int n){
	vector<int> V(n+n);
	iota(all(V), 1);
	solve(V);
}
/*int main(){
	//factinit();
	//BOOST
	int n=10;
	wynik.resize(n+n);
	iota(all(wynik), 2);
	for(int &i:wynik)i/=2;
	assert(wynik.size()==n+n);
	shuffle(all(wynik), rng);
	Solve(n);
	assert(ile_dobrze==n);
}*/

Compilation message

minerals.cpp: In function 'void solve(vi)':
minerals.cpp:155:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  155 |  for(int i=0; i<V2.size(); i++){
      |               ~^~~~~~~~~~
minerals.cpp:161:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  161 |  for(int i=0; i<V.size(); i++){
      |               ~^~~~~~~~~
minerals.cpp:168:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  168 |  for(int i=0; i<V.size(); i++){
      |               ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 336 KB Output is correct
2 Correct 4 ms 464 KB Output is correct
3 Correct 8 ms 780 KB Output is correct
4 Correct 16 ms 1232 KB Output is correct
5 Correct 40 ms 1884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 4 ms 464 KB Output is correct
7 Correct 8 ms 780 KB Output is correct
8 Correct 16 ms 1232 KB Output is correct
9 Correct 40 ms 1884 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 21 ms 1440 KB Output is correct
12 Correct 41 ms 1928 KB Output is correct
13 Correct 31 ms 1872 KB Output is correct
14 Correct 32 ms 1872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 4 ms 464 KB Output is correct
7 Correct 8 ms 780 KB Output is correct
8 Correct 16 ms 1232 KB Output is correct
9 Correct 40 ms 1884 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 21 ms 1440 KB Output is correct
12 Correct 41 ms 1928 KB Output is correct
13 Correct 31 ms 1872 KB Output is correct
14 Correct 32 ms 1872 KB Output is correct
15 Incorrect 45 ms 4376 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 4 ms 464 KB Output is correct
7 Correct 8 ms 780 KB Output is correct
8 Correct 16 ms 1232 KB Output is correct
9 Correct 40 ms 1884 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 21 ms 1440 KB Output is correct
12 Correct 41 ms 1928 KB Output is correct
13 Correct 31 ms 1872 KB Output is correct
14 Correct 32 ms 1872 KB Output is correct
15 Incorrect 45 ms 4376 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 4 ms 464 KB Output is correct
7 Correct 8 ms 780 KB Output is correct
8 Correct 16 ms 1232 KB Output is correct
9 Correct 40 ms 1884 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 21 ms 1440 KB Output is correct
12 Correct 41 ms 1928 KB Output is correct
13 Correct 31 ms 1872 KB Output is correct
14 Correct 32 ms 1872 KB Output is correct
15 Incorrect 45 ms 4376 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 4 ms 464 KB Output is correct
7 Correct 8 ms 780 KB Output is correct
8 Correct 16 ms 1232 KB Output is correct
9 Correct 40 ms 1884 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 21 ms 1440 KB Output is correct
12 Correct 41 ms 1928 KB Output is correct
13 Correct 31 ms 1872 KB Output is correct
14 Correct 32 ms 1872 KB Output is correct
15 Incorrect 45 ms 4376 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 4 ms 464 KB Output is correct
7 Correct 8 ms 780 KB Output is correct
8 Correct 16 ms 1232 KB Output is correct
9 Correct 40 ms 1884 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 21 ms 1440 KB Output is correct
12 Correct 41 ms 1928 KB Output is correct
13 Correct 31 ms 1872 KB Output is correct
14 Correct 32 ms 1872 KB Output is correct
15 Incorrect 45 ms 4376 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 4 ms 464 KB Output is correct
7 Correct 8 ms 780 KB Output is correct
8 Correct 16 ms 1232 KB Output is correct
9 Correct 40 ms 1884 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 21 ms 1440 KB Output is correct
12 Correct 41 ms 1928 KB Output is correct
13 Correct 31 ms 1872 KB Output is correct
14 Correct 32 ms 1872 KB Output is correct
15 Incorrect 45 ms 4376 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -