Submission #1345489

#TimeUsernameProblemLanguageResultExecution timeMemory
1345489duonghongducazBalloons (CEOI11_bal)C++20
Compilation error
0 ms0 KiB
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<vector>
using namespace std;
struct Ballon{
    long double x;
    long double r;
};

void Input(int& n, vector<Ballon>& ballons){
    cin >> n;
    ballons.resize(n+1);
    for(int i=0;i<n;i++){
        cin >> ballons[i].x >> ballons[i].r;
    }
}

double calculate_r2(long double x1, long double x2, long double r){
    return (x1-x2)*(x1-x2)/(4.0*r);
}

void processing(int n, vector<Ballon>& ballons){
    stack<pair<long double, long double>> s;
    for(int i=0;i<n;i++){
        long double current_r = ballons[i].r;
        while(!s.empty()){
            pair<long double, long double> last_circus = s.top();
            long double limit = calculate_r2(last_circus.first, ballons[i].x, last_circus.second);
            current_r = min(ballons[i].r, limit);
            if(current_r>=last_circus.second){
                s.pop();
                continue;
            }
            else{
                break;#include<iostream>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<vector>
using namespace std;
struct Ballon{
    long double x;
    long double r;
};

void Input(int& n, vector<Ballon>& ballons){
    cin >> n;
    ballons.resize(n+1);
    for(int i=0;i<n;i++){
        cin >> ballons[i].x >> ballons[i].r;
    }
}

double calculate_r2(long double x1, long double x2, long double r){
    return (x1-x2)*(x1-x2)/(4.0*r);
}

void processing(int n, vector<Ballon>& ballons){
    stack<pair<long double, long double>> s;
    for(int i=0;i<n;i++){
        long double current_r = ballons[i].r;
        while(!s.empty()){
            pair<long double, long double> last_circus = s.top();
            long double limit = calculate_r2(last_circus.first, ballons[i].x, last_circus.second);
            current_r = min(ballons[i].r, limit);
            if(current_r>=last_circus.second){
                s.pop();
                continue;
            }
            else{
                break;
            }
        }
        s.push({ballons[i].x, current_r});
        ballons[i].r = current_r;
    }
    for(int i=0;i<n;i++){
        cout << fixed << setprecision(3) << ballons[i].r << "\n";
    }
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    vector<Ballon> ballons;
    Input(n, ballons);
    processing(n, ballons);
    return 0;
}
            }
        }
        s.push({ballons[i].x, current_r});
        ballons[i].r = current_r;
    }
    for(int i=0;i<n;i++){
        cout << fixed << setprecision(3) << ballons[i].r << "\n";
    }
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    vector<Ballon> ballons;
    Input(n, ballons);
    processing(n, ballons);
    return 0;
}

Compilation message (stderr)

bal.cpp:37:23: error: stray '#' in program
   37 |                 break;#include<iostream>
      |                       ^
bal.cpp: In function 'void processing(int, std::vector<Ballon>&)':
bal.cpp:37:24: error: 'include' was not declared in this scope
   37 |                 break;#include<iostream>
      |                        ^~~~~~~
bal.cpp:37:40: error: expected primary-expression before '>' token
   37 |                 break;#include<iostream>
      |                                        ^
bal.cpp:42:1: error: expected primary-expression before 'using'
   42 | using namespace std;
      | ^~~~~
bal.cpp:48:44: error: a function-definition is not allowed here before '{' token
   48 | void Input(int& n, vector<Ballon>& ballons){
      |                                            ^
bal.cpp:56:67: error: a function-definition is not allowed here before '{' token
   56 | double calculate_r2(long double x1, long double x2, long double r){
      |                                                                   ^
bal.cpp:60:48: error: a function-definition is not allowed here before '{' token
   60 | void processing(int n, vector<Ballon>& ballons){
      |                                                ^
bal.cpp:85:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   85 | int main(){
      |         ^~
bal.cpp:85:9: note: remove parentheses to default-initialize a variable
   85 | int main(){
      |         ^~
      |         --
bal.cpp:85:9: note: or replace parentheses with braces to value-initialize a variable
bal.cpp:85:11: error: a function-definition is not allowed here before '{' token
   85 | int main(){
      |           ^