| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 895916 | nightfal | Wiring (IOI17_wiring) | C++14 | 20 ms | 4768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wiring.h"
#include <stdlib.h>
#include <algorithm>
using namespace std;
bool isSubtask1(std::vector<int> r, std::vector<int> b) {return r.size()<=200 && b.size()<=200;}
bool isSubtask2(std::vector<int> r, std::vector<int> b) {return r[r.size()-1]<b[0];}
bool isSubtask3(std::vector<int> r, std::vector<int> b) {
int n=r.size(), m=b.size();
vector<int> a(n+m);
for(int i=0, j=0; i<m || j<n;)
i==n? a[m+i++]= 0: j==m? a[n+j++] = 1: a[i+j] = r[i]<b[j]? r[i++]:b[j++];
int cnt = 1;
for(int k=1; k<n+m; k++) {
cnt = a[k]==a[k-1]? cnt+1:0;
if (cnt > 7) return false;
}
return true;
}
long long subtask1(std::vector<int>, std::vector<int>);
long long subtask2(std::vector<int>, std::vector<int>);
long long min_total_length(std::vector<int> r, std::vector<int> b) {
if (isSubtask1(r,b)) return subtask1(r,b);
else if (isSubtask2(r,b)) return subtask2(r,b);
}
long long subtask1(std::vector<int> r, std::vector<int> b) {
int n = r.size(), m = b.size();
long long dp[n][m];
dp[0][0] = abs(r[0]-b[0]);
for(int i=1; i<n; i++)
dp[i][0] = dp[i-1][0] + abs(r[i]-b[0]);
for(int j=1; j<m; j++)
dp[0][j] = dp[0][j-1] + abs(r[0]-b[j]);
for(int i=1; i<n; i++)
for(int j=1; j<m; j++)
dp[i][j] = min(min(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1]) + abs(r[i]-b[j]);
return dp[n-1][m-1];
}
long long subtask2(std::vector<int> r, std::vector<int> b) {
long long rSum=0, bSum=0, n = r.size(), m = b.size();
for(int i=0; i<n; i++) rSum += r[n-1] - r[i];
for(int i=0; i<m; i++) bSum += b[i] - b[0];
return rSum+bSum+max(n,m)*(b[0]-r[n-1]);
}컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
