QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#747326 | #9574. Strips | ucup-team1769# | Compile Error | / | / | C++14 | 3.8kb | 2024-11-14 16:53:39 | 2024-11-14 16:53:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void sol()
{
int n, m, k, w;
cin >> n >> m >> k >> w;
// poi, color R=1 B=2
vector<pair<int, int>> vec;
for (int i = 0; i < n; i++)
{
int p;
cin >> p;
vec.push_back({p, 1});
}
for (int i = 0; i < m; i++)
{
int p;
cin >> p;
vec.push_back({p, 2});
}
sort(vec.begin(), vec.end());
vec.push_back({w + 1, 2});
int beg_poi = 1;
int gai_poi = -1;
int gai_num = 0;
vector<int> ans_vec;
for (int i = 0; i < vec.size(); i++)
{
if(vec[i].second == 2)
{
if(vec[i].first < gai_poi + k)
{
if(gai_num * k > vec[i].first - beg_poi)
{
cout << "-1\n";
return;
}
else
{
int eind = vec[i].first;
for (int j = 1; j <= gai_num; j++)
{
if(ans_vec[ans_vec.size() - j] + k > eind)
{
ans_vec[ans_vec.size() - j] = eind - k;
eind -= k;
}
}
}
}
gai_poi = -1;
gai_num = 0;
beg_poi = vec[i].first + 1;
}
else
{
if(gai_poi == -1 || gai_poi + k <= vec[i].first)
{
gai_poi = vec[i].first;
ans_vec.push_back(vec[i].first);
gai_num++;
}
}
}
cout << ans_vec.size() << "\n";
for (int i = 0; i < ans_vec.size(); i++)
{
cout << ans_vec[i] << " ";
}
cout << "\n";
}
int main()
{
int T;
cin >> T;
while (T--)
{
sol();
}
}#include <bits/stdc++.h>
using namespace std;
void sol()
{
int n, m, k, w;
cin >> n >> m >> k >> w;
// poi, color R=1 B=2
vector<pair<int, int>> vec;
for (int i = 0; i < n; i++)
{
int p;
cin >> p;
vec.push_back({p, 1});
}
for (int i = 0; i < m; i++)
{
int p;
cin >> p;
vec.push_back({p, 2});
}
sort(vec.begin(), vec.end());
vec.push_back({w + 1, 2});
int beg_poi = 1;
int gai_poi = -1;
int gai_num = 0;
vector<int> ans_vec;
for (int i = 0; i < vec.size(); i++)
{
if(vec[i].second == 2)
{
if(vec[i].first < gai_poi + k)
{
if(gai_num * k > vec[i].first - beg_poi)
{
cout << "-1\n";
return;
}
else
{
int eind = vec[i].first;
for (int j = 1; j <= gai_num; j++)
{
if(ans_vec[ans_vec.size() - j] + k > eind)
{
ans_vec[ans_vec.size() - j] = eind - k;
eind -= k;
}
}
}
}
gai_poi = -1;
gai_num = 0;
beg_poi = vec[i].first + 1;
}
else
{
if(gai_poi == -1 || gai_poi + k <= vec[i].first)
{
gai_poi = vec[i].first;
ans_vec.push_back(vec[i].first);
gai_num++;
}
}
}
cout << ans_vec.size() << "\n";
for (int i = 0; i < ans_vec.size(); i++)
{
cout << ans_vec[i] << " ";
}
cout << "\n";
}
int main()
{
int T;
cin >> T;
while (T--)
{
sol();
}
}
Details
answer.code:83:2: error: stray ‘#’ in program 83 | }#include <bits/stdc++.h> | ^ answer.code:83:3: error: ‘include’ does not name a type 83 | }#include <bits/stdc++.h> | ^~~~~~~ answer.code:85:6: error: redefinition of ‘void sol()’ 85 | void sol() | ^~~ answer.code:3:6: note: ‘void sol()’ previously defined here 3 | void sol() | ^~~ answer.code:156:5: error: redefinition of ‘int main()’ 156 | int main() | ^~~~ answer.code:74:5: note: ‘int main()’ previously defined here 74 | int main() | ^~~~