제출 #1167687

#제출 시각아이디문제언어결과실행 시간메모리
1167687mychecksedadAliens (IOI16_aliens)C++20
12 / 100
155 ms1284 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> #include"aliens.h" using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 1e5+100, M = 1e5+10, K = 105, MX = 30; const ll INF = 1e18; int n, m, k; array<ll, 2> a[N]; ll dp[N][K], go[N]; ll take_photos(int nn, int mm, int kk, vector<int> r, vi c){ n=nn,m=mm,k=kk; for(int i=0;i<n;++i) a[i][0]=r[i],a[i][1]=c[i]; /* cin >> n >> m >> k; for(int i = 0; i < n; ++i) cin >> a[i][0] >> a[i][1]; */ for(int i = 0; i < n; ++i){ if(a[i][0] > a[i][1]){ swap(a[i][0], a[i][1]); } } sort(a, a+n, [&](const array<ll,2> &x, const array<ll, 2> &y){ return array<ll,2>{x[1],x[0]}<array<ll,2>{y[1],y[0]}; }); //for(int i = 0; i < n; ++i) cout << a[i][0] << ' ' << a[i][1] << '\n'; ll mn = MOD; int ptr = n - 1; for(int i = m; i >= 0; --i){ while(ptr >= 0 && a[ptr][1] >= i){ mn = min(mn, a[ptr][0]); --ptr; } go[i] = mn; } //for(int j = 0; j <= m; ++j) cout << go[j] << ' '; en; for(int j = 0; j <= k; ++j){ for(int i = 0; i <= m; ++i) dp[i][j] = INF; } for(int i = 0; i <=m; ++i) dp[i][1] = (go[0] > i ? 0ll : (go[0]-i)*(go[0]-i)); ll ans = INF; for(int j = 2; j <= k; ++j){ for(ll i = 1; i <= m; ++i){ ll best = 0; for(int last = 0; last <= i; ++last){ if(go[last] > i) continue; ll val = dp[last][j - 1] + (go[last] - i) * (go[last] - i); if(val <= dp[i][j]){ dp[i][j] = val; best = last; } } if(go[i] == MOD) ans=min(ans,dp[i][j]); best = max(best, (go[i])); if(j < k && go[i] <= i) dp[i][j] -= (best - i) * (best - i); //cout << i << ' ' << j << ' ' << dp[i][j] << '\n'; } //cout << '\n'; } for(int i = 1; i <= m; ++i) if(go[i] == MOD) ans = min(ans, dp[i][k]); //cout << ans; return ans; } /* int main(){ cin.tie(0); ios::sync_with_stdio(0); int tt = 1, aa; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(tt--){ // solve(); } cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n"; return 0; } */

컴파일 시 표준 에러 (stderr) 메시지

aliens.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
aliens_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...