이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// c4ts0up
// Alvaro Bacca - COL3
#include "paint.h"
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
int n, k;
vector <int> ps;
vector <int> ade, atr;
string cad;
// encuentra la interseccion de [a] union [b]. devuelve {-1,-1} si no hay
pair <int,int> interseccion(pair <int,int> a, pair <int,int> b) {
pair <int,int> res = {b.ff, a.ss};
if (b.ff > a.ss) return {-1,-1};
else return res;
}
string solve_puzzle(string s, vector<int> c) {
n = c.size();
k = s.size();
// llenamos el de adelante
for (int i=0; i<n; i++) {
for (int j=0; j<c[i]; j++) ade.pb(i+1);
if (ade.size()+1 <= k) ade.pb(-(i+1));
}
while (ade.size() < k) ade.pb(-n);
// llenamos el reverso
for (int i=n-1; i>=0; i--) {
for (int j=0; j<c[i]; j++) atr.pb(i+1);
if (atr.size()+1 <= k && i>0) atr.pb(-(i));
}
while (atr.size() < k) atr.pb(-n);
reverse(atr.begin(), atr.end());
/*//
cout << "ade := ";
for (int x : ade) cout << x << ", ";
cout << endl;
cout << "atr := ";
for (int x : atr) cout << x << ", ";
cout << endl;
//*/
// crea la cadena
for (int i=0; i<k; i++) {
if (ade[i] == atr[i]) cad += (ade[i] > 0 ? "X" : "_");
else cad += "?";
}
return cad;
}
컴파일 시 표준 에러 (stderr) 메시지
paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:30:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
30 | if (ade.size()+1 <= k) ade.pb(-(i+1));
| ~~~~~~~~~~~~~^~~~
paint.cpp:32:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
32 | while (ade.size() < k) ade.pb(-n);
| ~~~~~~~~~~~^~~
paint.cpp:37:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
37 | if (atr.size()+1 <= k && i>0) atr.pb(-(i));
| ~~~~~~~~~~~~~^~~~
paint.cpp:39:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
39 | while (atr.size() < k) atr.pb(-n);
| ~~~~~~~~~~~^~~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |