This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "simurgh.h"
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
vector<int> ans;
//int count_common_roads(vector<int> v) {
// for(auto it: v) cout << it << ' '; cout << endl;
// int a; cin >> a; return a;
//}
int dfs(int l, int r) {
vector<int> que;
for(int i = l; i <= r; i ++) que.push_back(i);
int v = count_common_roads(que);
if(!v) return 0;
if(v == r - l + 1) return ans.insert(ans.end(), que.begin(), que.end()), v;
int m = l + r >> 1;
int k = dfs(l, m);
if(k != v) dfs(m + 1, r);
}
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
dfs(0, u.size() - 1);
return ans;
}
//main () {
// vector<int> ans = find_roads(4, {0, 0, 0, 1, 1, 2}, {1, 2, 3, 2, 3, 3});
// for(auto it: ans) cout << it << ' '; cout << endl;
//}
Compilation message (stderr)
simurgh.cpp: In function 'int dfs(int, int)':
simurgh.cpp:18:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int m = l + r >> 1;
~~^~~
simurgh.cpp:21:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |