/ SeriousOJ /

Record Detail

Compile Error

foo.cc:86:18: error: '#' is not followed by a macro parameter
   86 | #define debug(...)                       \
      |                  ^

Code

/**
 *    author:  RedImposter
 *    created: 17.06.2025 17:11:14
 **/

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define life ios_base::sync_with_stdio(false);
#define saver cin.tie(0);
#define f first
#define sc second
#define rep(i, a, n) for (long long int i = (a); i <= (n); ++i)
#define repI(i, a, n) for (int i = (a); i <= (n); ++i)
#define repD(i, a, n) for (long long int i = (a); i >= (n); --i)
#define repDI(i, a, n) for (int i = (a); i >= (n); --i)
#define nxt cout << endl;
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define rall(x) (x).rbegin(), (x).rend()
#define INF (ll)1e18
#define inp(a)                        \
   for (int i = 0; i < a.size(); i++) \
   cin >> a[i]
#define out(a)                        \
   for (int i = 0; i < a.size(); i++) \
   cout << a[i] << " "
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<long long int> vll;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

const int mod = 1e9 + 7;
// Debugging helpers
void __print(int x) { cout << x; }
void __print(long x) { cout << x; }
void __print(long long x) { cout << x; }
void __print(unsigned x) { cout << x; }
void __print(unsigned long x) { cout << x; }
void __print(unsigned long long x) { cout << x; }
void __print(float x) { cout << x; }
void __print(double x) { cout << x; }
void __print(long double x) { cout << x; }
void __print(char x) { cout << '"' << x << '"'; }
void __print(const char *x) { cout << '"' << x << '"'; }
void __print(const string &x) { cout << '"' << x << '"'; }
void __print(bool x) { cout << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
   cout << '{';
   __print(x.first);
   cout << ',';
   __print(x.second);
   cout << '}';
}

template <typename T>
void __print(const T &x)
{
   int f = 0;
   cout << '{';
   for (auto &i : x)
   {
      if (f++)
         cout << ", ";
      __print(i);
   }
   cout << "}";
}

void _print() { cout << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
   __print(t);
   if (sizeof...(v))
      cout << ", ";
   _print(v...);
}

#ifndef ONLINE_JUDGE
#define debug(...)                       \
   cout << "[" << #_VA_ARGS_ << "] = ["; \
   print(VA_ARGS_)
#else
#define debug(...)
#endif

void RedImposter()
{
   string s, t;
   cin >> s;

   sort(all(s));
   int n = s.size();

   map<char, int> mp;
   int maxi = 0;

   for (int i = 0; i < n; i++)
   {
      mp[s[i]]++;
      maxi = max(maxi, mp[s[i]]);
   }

   if (maxi > (n + 1) / 2)
   {
      cout << -1;
      nxt return;
   }
   int j = 0;
   //   debug(t);
   //   debug(s);

   while (t.size() != n)
   {

      int m = n - t.size();
      int maxi2 = 0;
      char c;
      for (auto it : mp)
      {
         if (maxi2 < mp[it.f])
         {
            maxi2 = mp[it.f];
            c = it.f;
         }
      }
      // debug(maxi2,(m+1)/2);
      if ((m & 1) && maxi2 == (m + 1) / 2)
      {
         t += c;
         mp[c]--;
         continue;
      }
      // debug(t,s);
      for (auto it : mp)
      {
         if (it.f != t.back() && it.sc > 0)
         {
            t += it.f;
            mp[it.f]--;
            break;
         }
      }
   }

   cout << t;
   nxt
}

int main()
{
   life saver
   RedImposter();
   return 0;
}

Information

Submit By
Type
Submission
Problem
P1209 B. Rearrange the String
Contest
Educational Round 1
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-14 16:47:21
Judged At
2025-07-14 16:47:21
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes