Submission #241887

#TimeUsernameProblemLanguageResultExecution timeMemory
241887osaaateiasavtnlConstruction of Highway (JOI18_construction)C++17
7 / 100
2084 ms736 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ii pair <int, int> #define app push_back #define all(a) a.begin(), a.end() #define bp __builtin_popcountll #define ll long long #define mp make_pair #define f first #define s second #define Time (double)clock()/CLOCKS_PER_SEC const int N = 1e5+7; int n, a[N], par[N]; signed main() { #ifdef HOME freopen("input.txt", "r", stdin); #else #define endl '\n' ios_base::sync_with_stdio(0); cin.tie(0); #endif cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int t = 0; t < n - 1; ++t) { int u, v; cin >> u >> v; par[v] = u; vector <int> path; while (u) { path.app(a[u]); a[u] = a[v]; u = par[u]; } int ans = 0; for (int i = 0; i < path.size(); ++i) for (int j = i + 1; j < path.size(); ++j) ans += path[i] < path[j]; cout << ans << endl; } }

Compilation message (stderr)

construction.cpp: In function 'int main()':
construction.cpp:39:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < path.size(); ++i)   
                         ~~^~~~~~~~~~~~~
construction.cpp:40:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j = i + 1; j < path.size(); ++j)
                                 ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...