Submission #1359821

#TimeUsernameProblemLanguageResultExecution timeMemory
1359821Mamikonm1Rotating Lines (APIO25_rotate)C++20
Compilation error
0 ms0 KiB
#include "rotate.h"
#include <iostream>
#include <vector>
#include <cmath>
#include<map>
#include <algorithm>
#include <iomanip>
#include <string>
#include<stack>
#include <set>
#include <queue>
#include <chrono>
#include<array>
#include<bitset>
#include<unordered_map>
#include<random>
#include<cassert>
#include<cstring>
using namespace std;
using ll = long long;
using db = double;
const float pi = 3.14159265359;
#define V vector
#define VI V<int>
#define P pair<int,int>
#define rep(i, a, b, step) for (int i = int(a); i <= int(b); i += step)
#define repl(i,a,b,step) for (int i = int(a); i >= int(b); i -= step)
#define prime(n) [](int x) { for (int i = 2; i *1ll* i <= x; ++i) if (x % i == 0) return false; return x > 1; }(n)
#define printall(container, ch) for (const auto& elem : container) { std::cout << elem << ch; } std::cout << std::endl;
#define sn << '\n'
#define ed << endl
#define sz size()
#define print cout <<
#define debug(x) cerr<< #x << " = " << x sn;
#define mpII map<int,int>   
#define mine min_element    
#define maxe max_element    
#define all(v) begin(v), end(v)
#define txt freopen("snakes.in", "r", stdin); freopen("snakes.out", "w", stdout)    
#define MEX(a) [](VI a){set<int>elem;for(auto&i:a)elem.insert(i);int ret=0;while(elem.count(ret))ret++;return ret;}(a)
#define pb push_back    
#define pq priority_queue
#define rev reverse
#define nuyn(a) a.erase(unique(all(a)), end(a))
#define nx next_permutation         
#define pk pop_back()
#define START print "Start" sn
#define END print "End" sn
#define ff first
#define ss second       
#define ts to_string 
#define ub upper_bound       
#define mk make_pair 
#define lb lower_bound               
#define testcase int t;cin>>t;while(t--)solution();
const int mod = 5e4;

vector<int>a;

int ok(int a) {
    return (a + mod) % mod;
}

void rotat(std::vector<int> t, int x) {
    rotate(t, x);
    for (auto& i : t)a[i] = ok(a[i] + x);
}


void energy(int n, std::vector<int> v) {
    a = v;
    int cnt1 = 0, cnt2 = 0, c1 = (n + 1) / 2, c2 = n / 2;
    rep(i, 0, n - 1, 1) {
        cnt1 += (a[i] == 0);
        cnt2 += (a[i] == 25000);
    }
    rep(i, 0, n - 1, 1) {
        if (cnt1 < c1 and a[i] != 25000 and a[i]) {
            cnt1++;
            rotat({ i }, ok(25000 - a[i]));
        
        else if (cnt2 < c2 and a[i] != 25000 and a[i]) {
            cnt2++;
            rotat({ i }, 50000 - a[i]);
        }
    }
    rep(i, 0, n - 1, 1) {
        if (cnt1 > c1 and !a[i]) {
            cnt1--;
            cnt2++;
            rotat({ i }, 25000);
        }
        else if (cnt2 > c2) {
            cnt2--;
            cnt1++;
            rotat({ i }, 25000);
        }
    }
}

Compilation message (stderr)

rotate.cpp: In function 'void energy(int, std::vector<int>)':
rotate.cpp:82:9: error: expected '}' before 'else'
   82 |         else if (cnt2 < c2 and a[i] != 25000 and a[i]) {
      |         ^~~~
rotate.cpp:78:51: note: to match this '{'
   78 |         if (cnt1 < c1 and a[i] != 25000 and a[i]) {
      |                                                   ^