#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=5;
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++){
| ~^~~~~~~~~
minerals.cpp: In instantiation of 'std::ostream& operator<<(std::ostream&, std::vector<_Tp>) [with H = int; std::ostream = std::basic_ostream<char>]':
minerals.cpp:39:30: required from 'void debug(H, T ...) [with H = std::vector<int>; T = {}]'
minerals.cpp:144:2: required from here
minerals.cpp:29:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int i=0; i<V.size(); i++){
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
13 ms |
356 KB |
Output is correct |
4 |
Correct |
10 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
152 ms |
544 KB |
Output is correct |
2 |
Correct |
261 ms |
952 KB |
Output is correct |
3 |
Correct |
558 ms |
1696 KB |
Output is correct |
4 |
Execution timed out |
1189 ms |
3172 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
13 ms |
356 KB |
Output is correct |
4 |
Correct |
10 ms |
344 KB |
Output is correct |
5 |
Correct |
152 ms |
544 KB |
Output is correct |
6 |
Correct |
261 ms |
952 KB |
Output is correct |
7 |
Correct |
558 ms |
1696 KB |
Output is correct |
8 |
Execution timed out |
1189 ms |
3172 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
13 ms |
356 KB |
Output is correct |
4 |
Correct |
10 ms |
344 KB |
Output is correct |
5 |
Correct |
152 ms |
544 KB |
Output is correct |
6 |
Correct |
261 ms |
952 KB |
Output is correct |
7 |
Correct |
558 ms |
1696 KB |
Output is correct |
8 |
Execution timed out |
1189 ms |
3172 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
13 ms |
356 KB |
Output is correct |
4 |
Correct |
10 ms |
344 KB |
Output is correct |
5 |
Correct |
152 ms |
544 KB |
Output is correct |
6 |
Correct |
261 ms |
952 KB |
Output is correct |
7 |
Correct |
558 ms |
1696 KB |
Output is correct |
8 |
Execution timed out |
1189 ms |
3172 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
13 ms |
356 KB |
Output is correct |
4 |
Correct |
10 ms |
344 KB |
Output is correct |
5 |
Correct |
152 ms |
544 KB |
Output is correct |
6 |
Correct |
261 ms |
952 KB |
Output is correct |
7 |
Correct |
558 ms |
1696 KB |
Output is correct |
8 |
Execution timed out |
1189 ms |
3172 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
13 ms |
356 KB |
Output is correct |
4 |
Correct |
10 ms |
344 KB |
Output is correct |
5 |
Correct |
152 ms |
544 KB |
Output is correct |
6 |
Correct |
261 ms |
952 KB |
Output is correct |
7 |
Correct |
558 ms |
1696 KB |
Output is correct |
8 |
Execution timed out |
1189 ms |
3172 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
13 ms |
356 KB |
Output is correct |
4 |
Correct |
10 ms |
344 KB |
Output is correct |
5 |
Correct |
152 ms |
544 KB |
Output is correct |
6 |
Correct |
261 ms |
952 KB |
Output is correct |
7 |
Correct |
558 ms |
1696 KB |
Output is correct |
8 |
Execution timed out |
1189 ms |
3172 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
13 ms |
356 KB |
Output is correct |
4 |
Correct |
10 ms |
344 KB |
Output is correct |
5 |
Correct |
152 ms |
544 KB |
Output is correct |
6 |
Correct |
261 ms |
952 KB |
Output is correct |
7 |
Correct |
558 ms |
1696 KB |
Output is correct |
8 |
Execution timed out |
1189 ms |
3172 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |