CSES - Datatähti 2022 alku - Results
Submission details
Task:Spiraali
Sender:jusola
Submission time:2021-10-10 21:08:02 +0300
Language:C++11
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int getltop(int, int)':
input/code.cpp:24:32: error: expression cannot be used as a function
     int res = ((n-2)/2)((n-2)/2);
                                ^

Code

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

#define ll long long

using namespace std;

int gne(int n, int x, int y) {
    vector<int> dists;
    dists.push_back(y);
    dists.push_back(n-y-1);
    dists.push_back(x);
    dists.push_back(n-x-1);

    int m = *min_element(dists.begin(), dists.end());

    return m;
}

int getltop(int n, int l) {
    int res = ((n-2)/2)((n-2)/2);
    //cout << "n: " << n << "\n";
    return res;
}

int test(int n, int x, int y) {
    int l = gne(n,x,y);
    int ltop = getltop(n,l);

    int llen = n-2*l-1;

    //cout << "l: " << l << "ltop: " << ltop << " llen: " << llen <<"\n";

    if (x == l){
        //cout << "left";
        return ltop + (y - l);
    }

    if ((y-l) == llen) {
        //cout << "bot";
        return ltop + llen + (x-l);
    }

    if ((x-l) == llen) {
        //cout << "right";
        return ltop + 3*llen - (y-l);
    }

    if (y == l) {
        //cout << "top";
        return ltop + 4*llen - (x-l);
    }

    //cout << "FAIL\n";
    return 0;


}

int main() {
    int n, t;
    cin >> n >> t;

    

    for(int i=0; i<t; i++){
        int x, y;
        cin >> y >> x;
        cout << test(n,x-1,y-1) << "\n";
    }

    return 0;

}