Submission #303300

# Submission time Handle Problem Language Result Execution time Memory
303300 2020-09-20T07:32:52 Z Vimmer Comparing Plants (IOI20_plants) C++14
0 / 100
21 ms 28544 KB
#include <bits/stdc++.h>
#include "plants.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define N 200005
#define PB push_back
#define sz(x) int(x.size())
#define P 31
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//typedef tree<int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll mlt(ll a, ll b) {return (a * b) % M;}
ll sm(ll a, ll b) {return (a + b) % M;}

int K, h[N], glob, val[N];

vector <int> gr;

set <int> g[N], se, st[N], ht[N];

void dfs(int v)
{
    st[v].insert(glob);

    ht[v].insert(h[v]);

    for (auto it : g[v])
    {
        if (val[it] == glob)
        {
            if (h[v] + 1 > h[it]) ht[it].erase(h[it]);
              else continue;
        }

        h[it] = h[v] + 1;

        val[it] = glob;

        dfs(it);
    }
}

void init(int k, vector<int> r)
{
    gr = r;

    K = k;

    if (K == 2)
    {
        for (int i = 0; i < sz(r); i++) {val[i] = 1e9; se.insert(i);}

        for (int i = 0; i < sz(r); i++)
        {
            int nxt = (i + 1) % sz(r);

            if (r[i] == 1) {g[nxt].insert(i); se.erase(i);}
              else {g[i].insert(nxt);se.erase(nxt);}
        }

        for (auto it : se) {glob = it; dfs(it);}
    }

	return;
}

int compare_plants(int x, int y)
{
    bool f = 1;

    for (auto it : st[x]) if (st[y].find(it) != st[y].end()) f = 0;

    if (f) return 0;

    bool f1 = 1, f2 = 1;

    for (auto it : ht[x])
    {
        if (*ht[y].rbegin() >= it) f1 = 0;

        if (*ht[y].begin() <= it) f2 = 0;
    }

    if (!f1 && !f2) return 0;

    if (f1) return -1;

    if (f2) return 1;

	return 0;
}

//int main()
//{
////    freopen("help.in", "r", stdin); freopen("help.out", "w", stdout);
//
//    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//
//
//}
# Verdict Execution time Memory Grader output
1 Correct 19 ms 28544 KB Output is correct
2 Correct 19 ms 28544 KB Output is correct
3 Correct 19 ms 28544 KB Output is correct
4 Correct 19 ms 28544 KB Output is correct
5 Incorrect 19 ms 28544 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 28544 KB Output is correct
2 Correct 19 ms 28544 KB Output is correct
3 Incorrect 20 ms 28544 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 28544 KB Output is correct
2 Correct 19 ms 28544 KB Output is correct
3 Incorrect 20 ms 28544 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 28544 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 28544 KB Output is correct
2 Correct 21 ms 28472 KB Output is correct
3 Incorrect 20 ms 28544 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 28544 KB Output is correct
2 Correct 19 ms 28544 KB Output is correct
3 Incorrect 19 ms 28536 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 28544 KB Output is correct
2 Correct 19 ms 28544 KB Output is correct
3 Correct 19 ms 28544 KB Output is correct
4 Correct 19 ms 28544 KB Output is correct
5 Incorrect 19 ms 28544 KB Output isn't correct
6 Halted 0 ms 0 KB -