이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;
long long min_total_length( vector<int> r, vector<int> b ) {
int i = 0, j = 0;
long long cost = 0;
queue<int> q;
while ( i < r.size() && j < b.size() ) {
if ( r[i] < b[j] ) {
if ( i < j ) {
cost += r[i] - q.front(), printf( "%d %d\n", r[i], q.front() );
q.pop();
} else
q.push( r[i] );
i++;
} else {
if ( j < i ) {
cost += b[j] - q.front(), printf( "%d %d\n", b[j], q.front() );;
q.pop();
} else
q.push( b[j] );
j++;
}
}
while ( i < r.size() ) {
if ( !q.empty() ) {
cost += r[i] - q.front();
q.pop();
} else
cost += r[i] - b.back();
i++;
}
while ( j < b.size() ) {
if ( !q.empty() ) {
cost += b[j] - q.front();
q.pop();
} else
cost += b[j] - r.back();
j++;
}
if ( q.empty() )
return cost;
i = 0, j = 0;
cost = 0;
while ( !q.empty() )
q.pop();
reverse( r.begin(), r.end() );
reverse( b.begin(), b.end() );
while ( i < r.size() && j < b.size() ) {
if ( r[i] > b[j] ) {
if ( i < j ) {
cost += r[i] - q.front(), printf( "%d %d\n", r[i], q.front() );
q.pop();
} else
q.push( r[i] );
i++;
} else {
if ( j < i ) {
cost += b[j] - q.front(), printf( "%d %d\n", b[j], q.front() );;
q.pop();
} else
q.push( b[j] );
j++;
}
}
while ( i < r.size() ) {
if ( !q.empty() ) {
cost += r[i] - q.front();
q.pop();
} else
cost += r[i] - b.back();
i++;
}
while ( j < b.size() ) {
if ( !q.empty() ) {
cost += b[j] - q.front();
q.pop();
} else
cost += b[j] - r.back();
j++;
}
return -cost;
}
컴파일 시 표준 에러 (stderr) 메시지
wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
11 | while ( i < r.size() && j < b.size() ) {
| ~~^~~~~~~~~~
wiring.cpp:11:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
11 | while ( i < r.size() && j < b.size() ) {
| ~~^~~~~~~~~~
wiring.cpp:28:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | while ( i < r.size() ) {
| ~~^~~~~~~~~~
wiring.cpp:36:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | while ( j < b.size() ) {
| ~~^~~~~~~~~~
wiring.cpp:54:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | while ( i < r.size() && j < b.size() ) {
| ~~^~~~~~~~~~
wiring.cpp:54:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | while ( i < r.size() && j < b.size() ) {
| ~~^~~~~~~~~~
wiring.cpp:71:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
71 | while ( i < r.size() ) {
| ~~^~~~~~~~~~
wiring.cpp:79:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
79 | while ( j < b.size() ) {
| ~~^~~~~~~~~~
# | 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... |