#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 id;
vector <pair <int, int> > gt[N];
set <int> g[N];
void dfs(int v)
{
pair <int, int> pt;
pt.F = id++;
for (auto it : g[v])
dfs(it);
pt.S = id++;
gt[v].PB(pt);
}
void init(int k, vector<int> r)
{
if (k == 2)
{
set <int> se; se.clear();
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)
{
for (auto it : gt[x])
for (auto itr : gt[y])
if (it.F <= itr.F && itr.S <= it.S) return 1;
else if (itr.F <= it.F && it.S <= itr.S) 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);
//
//
//}
Compilation message
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:76:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
76 | for (auto it : gt[x])
| ^~~
plants.cpp:81:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
81 | return 0;
| ^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14464 KB |
Output is correct |
2 |
Correct |
10 ms |
14336 KB |
Output is correct |
3 |
Correct |
10 ms |
14336 KB |
Output is correct |
4 |
Correct |
10 ms |
14336 KB |
Output is correct |
5 |
Correct |
10 ms |
14464 KB |
Output is correct |
6 |
Correct |
79 ms |
17196 KB |
Output is correct |
7 |
Correct |
104 ms |
18968 KB |
Output is correct |
8 |
Correct |
223 ms |
34552 KB |
Output is correct |
9 |
Correct |
215 ms |
34044 KB |
Output is correct |
10 |
Correct |
226 ms |
34424 KB |
Output is correct |
11 |
Correct |
219 ms |
35576 KB |
Output is correct |
12 |
Correct |
226 ms |
38904 KB |
Output is correct |
13 |
Correct |
225 ms |
43384 KB |
Output is correct |
14 |
Correct |
219 ms |
43384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14336 KB |
Output is correct |
2 |
Correct |
10 ms |
14464 KB |
Output is correct |
3 |
Incorrect |
10 ms |
14336 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14336 KB |
Output is correct |
2 |
Correct |
10 ms |
14464 KB |
Output is correct |
3 |
Incorrect |
10 ms |
14336 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
14464 KB |
Output is correct |
2 |
Incorrect |
10 ms |
14336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14336 KB |
Output is correct |
2 |
Correct |
11 ms |
14336 KB |
Output is correct |
3 |
Correct |
10 ms |
14336 KB |
Output is correct |
4 |
Incorrect |
10 ms |
14336 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14336 KB |
Output is correct |
2 |
Correct |
10 ms |
14464 KB |
Output is correct |
3 |
Correct |
10 ms |
14464 KB |
Output is correct |
4 |
Incorrect |
10 ms |
14336 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14464 KB |
Output is correct |
2 |
Correct |
10 ms |
14336 KB |
Output is correct |
3 |
Correct |
10 ms |
14336 KB |
Output is correct |
4 |
Correct |
10 ms |
14336 KB |
Output is correct |
5 |
Correct |
10 ms |
14464 KB |
Output is correct |
6 |
Correct |
79 ms |
17196 KB |
Output is correct |
7 |
Correct |
104 ms |
18968 KB |
Output is correct |
8 |
Correct |
223 ms |
34552 KB |
Output is correct |
9 |
Correct |
215 ms |
34044 KB |
Output is correct |
10 |
Correct |
226 ms |
34424 KB |
Output is correct |
11 |
Correct |
219 ms |
35576 KB |
Output is correct |
12 |
Correct |
226 ms |
38904 KB |
Output is correct |
13 |
Correct |
225 ms |
43384 KB |
Output is correct |
14 |
Correct |
219 ms |
43384 KB |
Output is correct |
15 |
Correct |
10 ms |
14336 KB |
Output is correct |
16 |
Correct |
10 ms |
14464 KB |
Output is correct |
17 |
Incorrect |
10 ms |
14336 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |