답안 #303284

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
303284 2020-09-20T07:06:56 Z Vimmer 식물 비교 (IOI20_plants) C++14
0 / 100
8 ms 9760 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];

vector <int> gr;

set <int> g[N], se;

void dfs(int v)
{
    for (auto it : g[v])
    {
        if (h[it] >= h[v] + 1) continue;

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

        dfs(it);
    }
}

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

    K = k;

    if (K == 2)
    {
        for (int i = 0; i < sz(r); i++) 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) dfs(it);
    }

	return;
}

int compare_plants(int x, int y)
{
    if (se.find(x) != se.end() && se.find(y) != se.end()) return 0;

    if (h[x] < h[y]) return 1;

    if (h[x] > h[y]) 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);
//
//    init(2, {0, 1, 0, 1});
//
//    cout << compare_plants(0, 3) << endl;
//
//    cout << compare_plants(1, 3) << endl;
//}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 9728 KB Output is correct
2 Correct 7 ms 9728 KB Output is correct
3 Correct 8 ms 9728 KB Output is correct
4 Incorrect 7 ms 9728 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 9728 KB Output is correct
2 Correct 7 ms 9728 KB Output is correct
3 Incorrect 7 ms 9728 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 9728 KB Output is correct
2 Correct 7 ms 9728 KB Output is correct
3 Incorrect 7 ms 9728 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 9760 KB Output is correct
2 Incorrect 7 ms 9728 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 9728 KB Output is correct
2 Correct 6 ms 9728 KB Output is correct
3 Incorrect 7 ms 9728 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 9728 KB Output is correct
2 Correct 7 ms 9728 KB Output is correct
3 Incorrect 7 ms 9728 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 9728 KB Output is correct
2 Correct 7 ms 9728 KB Output is correct
3 Correct 8 ms 9728 KB Output is correct
4 Incorrect 7 ms 9728 KB Output isn't correct
5 Halted 0 ms 0 KB -