CSES - Datatähti 2025 alku - Results
Submission details
Task:Robotti
Sender:aksu
Submission time:2024-11-04 20:26:57 +0200
Language:C++ (C++20)
Status:COMPILE ERROR

Compiler report

input/code.cpp:64:9: warning: "/*" within comment [-Wcomment]
   64 |         /*while (true) {
      |          
input/code.cpp:136:17: warning: "/*" within comment [-Wcomment]
  136 |                 /*cout << "roP = " << roP << "\n";
      |                  
input/code.cpp:162:17: warning: "/*" within comment [-Wcomment]
  162 |                 /*c = ro;
      |                  
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
collect2: error: ld returned 1 exit status

Code

#include <iostream>
/*
#include <vector>
#include <cmath>
#include <chrono>
#include <algorithm>
#include <iomanip>
#include <sstream>
using namespace std;
typedef long long ll;
vector<char> v;
vector<int> x;
ll n;
string a;
ll lH;
ll riH;
ll roH;
long unsigned int c;
ll as = 0;
ll k = 0;
int roP;
int main() {
cin >> n;
cin >> a;
for (int i = 0; i < n; i++) {
v.push_back(a[i]);
if (a[i] == 'R') {
roH = i;
roP = x.size();
}
if (v[i] == '*') {
x.push_back(i);
}
}
for (int i = 0; i < x.size(); i++) {
cout << x[i];
}
cout << "\n";
bool doLeft = true;
bool doRight = true;
while (true) {
}
/*while (true) {
for (int i = 0; i < x.size(); i++) {
cout << x[i];
}
cout << "left: " << lH << "\n";
cout << "right: " << riH << "\n";
cout << "roP: " << roP << "\n";
cout << "\n";
if (roP == 0) {
lH = -1;
doLeft = false;
}
if (roP+2 == x.size()) {
riH = -1;
doRight = false;
}
if (doRight) {
cout << "roP : "<< roP << "\n";
riH = x[roP];
}
if (doLeft) {
cout << "doLeft\n";
if (x.size() > 1) lH = x[roP-1];
}
if (roH - lH == riH - roH || roH == -1 && lH == -1 || x.size() == 0) {
cout << as << " " << k;
break;
}
cout << "left: " << lH << "\n";
cout << "right: " << riH << "\n";
if (roH - lH < riH - roH && lH > 0 && riH > 0 || riH == -1 && lH > 0) {
cout << "l < r\n";
as += roH - lH;
k++;
roH = lH;
swap(x[roP - 1], x.back());
x.pop_back();
}
if (roH - lH > riH - roH && riH > 0 && lH > 0 || lH == -1 && riH > 0) {
cout << "r < l\n";
as += riH - roH;
k++;
roH = riH;
swap(x[roP], x.back());
x.pop_back();
}
if (roH - lH == riH - roH || roH == -1 && lH == -1 || x.size() == 0) {
cout << as << " " << k;
break;
}
}
while (true) {
/*cout << "roP = " << roP << "\n";
if (roP == 0) {
lH = -1;
doLeft = false;
cout << doLeft << "aaaa" << "\n";
}
if (roP + 1 == x.size()) {
riH = -1;
doRight = false;
cout << doRight << "bbbb" << "\n";
}
if (doRight == true) {
cout << "getRight" << "\n";
cout << x[roP + 1] << "\n";
riH = x[roP + 1];
}
if (doLeft == true) {
cout << "getLeft";
lH = x[roP - 1];
}
cout << "\n\n";
if (roH-lH == riH-roH || riH == -1 && lH == -1) {
cout << as << " " << k;
break;
}
/*c = ro;
while (true) {
if (c == 0) {
l = 100001;
break;
}
c--;
if (v[c] == '*') {
l = ro - c;
break;
}
}
c = ro;
while (true) {
if (c+1 == v.size()) {
ri = 100001;
break;
}
c++;
if (v[c] == '*') {
ri = c - ro;
break;
}
}
cout << "right = " << ri << "\n";
cout << "left = " << l << "\n";
if (rob-l < ri-rob && l != -1 || l != -1 && ri == -1) {
as += rob-l;
k++;
rob = l;
swap(x[roP-1], x.back());
x.pop_back();
}
else if (ri-rob < rob-l && ri != -1 || ri != -1 && l == -1) {
as += ri-rob;
k++;
rob = ri;
swap(x[roP + 1], x.back());
x.pop_back();
}
break;
}
}
*/