Submission #895034

#TimeUsernameProblemLanguageResultExecution timeMemory
895034hariaakas646Group Photo (JOI21_ho_t3)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define scd(t) scanf("%d", &t) #define sclld(t) scanf("%lld", &t); #define forr(i, l, r) for(int i=l; i<r; i++) #define frange(i, l) forr(i, 0, l) #define pb push_back #define mp make_pair #define f first #define s second #define all(x) x.begin(), x.end() typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pii> vii; typedef long long lli; typedef vector<vi> vvi; typedef vector<lli> vll; typedef vector<bool> vb; void usaco() { freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin); } int main() { // usaco(); int n; scd(n); vi vec(n); frange(i, n) scd(vec[i]); vector<vector<pair<int, vi>>> dp(n, vector<pair<int, vi>>(n)); frange(i, n) { vi tmp; tmp.pb(vec[i]); dp[i][i] = mp(i, tmp); } forr(i, 1, n) { for(int l=0; l+i<n; l++) { int r = l+i; auto p1 = dp[l][r-1]; p1.s.pb(vec[r]); int j = p1.s.size()-1; while(j > 0 && p1.s[j] + 2 <= p1.s[j-1]) { p1.f++; swap(p1.s[j], p1.s[j-1]); j--; } auto p2 = dp[l+1][r]; vi tmp; tmp.pb(vec[l]); for(auto e : p2.s) tmp.pb(e); j = 0; while(j < p2.s.size()-1 && p2.s[j] >= p2.s[j+1]+2) { p2.f++; swap(p2.s[j], p2.s[j-1]); j++; } dp[l][r] = min(p1, p2); } } printf("%d", dp[0][n-1].f); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:62:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |    while(j < p2.s.size()-1 && p2.s[j] >= p2.s[j+1]+2) {
      |          ~~^~~~~~~~~~~~~~~
Main.cpp: In function 'void usaco()':
Main.cpp:24:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
Main.cpp:30:2: note: in expansion of macro 'scd'
   30 |  scd(n);
      |  ^~~
Main.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
Main.cpp:33:15: note: in expansion of macro 'scd'
   33 |  frange(i, n) scd(vec[i]);
      |               ^~~
#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...