Submission #553216

# Submission time Handle Problem Language Result Execution time Memory
553216 2022-04-25T06:20:38 Z Killer2501 Chameleon's Love (JOI20_chameleon) C++14
100 / 100
51 ms 2872 KB
#include "chameleon.h"
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pll pair<int, pii>
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;
const int N = 1e5+2;
const int M = 60;
const int mod = 1e9+7;
const ll base = 1e6;
const ll inf = 1e9;
int n, m, b[N], a[N], k, t, d[N], cnt, par[N], f[N];
ll ans;
vector<int> adj[N];
bool vis[N], ok;
 
bool ask(vector<int> vi, int x)
{
    if(vi.empty())return false;
    vi.pb(x);
    return Query(vi) != (int) vi.size();
}
void Solve(int n)
{
    n *= 2;
    for(int i = 1; i <= n; i ++)
    {
        vector<int> group[2];
        fill_n(a, i, -1);
        queue<int> q;
        for(int j = 1; j < i; j ++)
        {
            if(a[j] == -1)
            {
                a[j] = 0;
                q.push(j);
                while(!q.empty())
                {
                    int u = q.front();
                    q.pop();
                    for(int v: adj[u])
                    {
                        if(a[v] == -1)
                        {
                            a[v] = a[u]^1;
                            q.push(v);
                        }
                    }
                }
            }
            group[a[j]].pb(j);
        }
        for(int j = 0; j < 2; j ++)
        {
            while(ask(group[j], i))
            {
                int l = 1, r = group[j].size(), mid;
                while(l <= r)
                {
                    mid = (l+r)>>1;
                    if(ask(vector<int>(group[j].begin(), group[j].begin()+mid), i))r = mid-1;
                    else l = mid+1;
                }
                adj[group[j][l-1]].pb(i);
                adj[i].pb(group[j][l-1]);
                group[j].erase(group[j].begin(), group[j].begin()+l);
            }
        }
    }
    for(int i = 1; i <= n; i ++)
    {
        if(adj[i].size() == 1)continue;
        while(Query({i, adj[i][0], adj[i][1]}) != 1)
            rotate(adj[i].begin(), adj[i].begin()+1, adj[i].end());
        b[adj[i][2]] ^= i;
        b[i] ^= adj[i][2]; 
    }
    for(int i = 1; i <= n; i ++)
    {
        if(adj[i].size() == 1)b[i] = adj[i][0];
        else for(int j = 0; j < 3; j ++)b[i] ^= adj[i][j];
        if(b[i] > i)Answer(i, b[i]);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 32 ms 2756 KB Output is correct
4 Correct 32 ms 2752 KB Output is correct
5 Correct 33 ms 2740 KB Output is correct
6 Correct 32 ms 2752 KB Output is correct
7 Correct 32 ms 2752 KB Output is correct
8 Correct 31 ms 2640 KB Output is correct
9 Correct 33 ms 2736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 1 ms 2640 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 1 ms 2640 KB Output is correct
6 Correct 2 ms 2640 KB Output is correct
7 Correct 2 ms 2640 KB Output is correct
8 Correct 2 ms 2640 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 1 ms 2640 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 1 ms 2640 KB Output is correct
6 Correct 2 ms 2640 KB Output is correct
7 Correct 2 ms 2640 KB Output is correct
8 Correct 2 ms 2640 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 2 ms 2640 KB Output is correct
11 Correct 2 ms 2640 KB Output is correct
12 Correct 2 ms 2640 KB Output is correct
13 Correct 2 ms 2640 KB Output is correct
14 Correct 2 ms 2640 KB Output is correct
15 Correct 2 ms 2640 KB Output is correct
16 Correct 2 ms 2640 KB Output is correct
17 Correct 2 ms 2640 KB Output is correct
18 Correct 2 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 50 ms 2872 KB Output is correct
4 Correct 51 ms 2740 KB Output is correct
5 Correct 48 ms 2860 KB Output is correct
6 Correct 49 ms 2760 KB Output is correct
7 Correct 48 ms 2748 KB Output is correct
8 Correct 47 ms 2752 KB Output is correct
9 Correct 49 ms 2740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 32 ms 2756 KB Output is correct
4 Correct 32 ms 2752 KB Output is correct
5 Correct 33 ms 2740 KB Output is correct
6 Correct 32 ms 2752 KB Output is correct
7 Correct 32 ms 2752 KB Output is correct
8 Correct 31 ms 2640 KB Output is correct
9 Correct 33 ms 2736 KB Output is correct
10 Correct 2 ms 2640 KB Output is correct
11 Correct 1 ms 2640 KB Output is correct
12 Correct 1 ms 2640 KB Output is correct
13 Correct 2 ms 2640 KB Output is correct
14 Correct 1 ms 2640 KB Output is correct
15 Correct 2 ms 2640 KB Output is correct
16 Correct 2 ms 2640 KB Output is correct
17 Correct 2 ms 2640 KB Output is correct
18 Correct 1 ms 2640 KB Output is correct
19 Correct 2 ms 2640 KB Output is correct
20 Correct 2 ms 2640 KB Output is correct
21 Correct 2 ms 2640 KB Output is correct
22 Correct 2 ms 2640 KB Output is correct
23 Correct 2 ms 2640 KB Output is correct
24 Correct 2 ms 2640 KB Output is correct
25 Correct 2 ms 2640 KB Output is correct
26 Correct 2 ms 2640 KB Output is correct
27 Correct 2 ms 2640 KB Output is correct
28 Correct 1 ms 2640 KB Output is correct
29 Correct 1 ms 2640 KB Output is correct
30 Correct 50 ms 2872 KB Output is correct
31 Correct 51 ms 2740 KB Output is correct
32 Correct 48 ms 2860 KB Output is correct
33 Correct 49 ms 2760 KB Output is correct
34 Correct 48 ms 2748 KB Output is correct
35 Correct 47 ms 2752 KB Output is correct
36 Correct 49 ms 2740 KB Output is correct
37 Correct 48 ms 2756 KB Output is correct
38 Correct 33 ms 2744 KB Output is correct
39 Correct 48 ms 2744 KB Output is correct
40 Correct 48 ms 2656 KB Output is correct
41 Correct 49 ms 2756 KB Output is correct
42 Correct 32 ms 2640 KB Output is correct
43 Correct 48 ms 2760 KB Output is correct
44 Correct 49 ms 2756 KB Output is correct
45 Correct 48 ms 2744 KB Output is correct