Submission #408872

#TimeUsernameProblemLanguageResultExecution timeMemory
408872mat_vGroup Photo (JOI21_ho_t3)C++14
64 / 100
5071 ms452 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i)) #define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i)) #define mod 998244353 #define xx first #define yy second #define all(a) (a).begin(), (a).end() #define pb push_back #define ll long long #define pii pair<int,int> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less) mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); int n; int niz[5005]; int dp[5005]; int ans[5005]; int poz[5005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; ff(i,1,n){ cin >> niz[i]; poz[niz[i]] = i; } dp[n] = 0; fb(i,n-1,0){ ans[0] = 0; dp[i] = 1e9; ff(j,i+1,n){ ans[j-i] = ans[j-i-1]; ff(r,1,poz[j] - 1){ if(niz[r] > i)ans[j-i]++; } ff(r,poz[j]+1,n){ if(niz[r] < j && niz[r] > i)ans[j-i]--; } dp[i] = min(dp[i], ans[j-i] + dp[j]); } } cout << dp[0] << "\n"; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
Main.cpp:35:5: note: in expansion of macro 'ff'
   35 |     ff(i,1,n){
      |     ^~
Main.cpp:7:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
      |                           ^
Main.cpp:40:5: note: in expansion of macro 'fb'
   40 |     fb(i,n-1,0){
      |     ^~
Main.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
Main.cpp:43:9: note: in expansion of macro 'ff'
   43 |         ff(j,i+1,n){
      |         ^~
Main.cpp:6:27: warning: unnecessary parentheses in declaration of 'r' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
Main.cpp:45:13: note: in expansion of macro 'ff'
   45 |             ff(r,1,poz[j] - 1){
      |             ^~
Main.cpp:6:27: warning: unnecessary parentheses in declaration of 'r' [-Wparentheses]
    6 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
Main.cpp:48:13: note: in expansion of macro 'ff'
   48 |             ff(r,poz[j]+1,n){
      |             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...