UCSD ICPC Club Nov27 A

Since final is approaching, this week’s club problems were very very simple yet numerous, the number of participants has also decreased, making it somewhat boring.

This was the first problem I solved, I expected to solve it in 3 mins, but took 4 mins.

There are four cases:
1. If the lowest digit is already an even number, 0
2. If every digits are odd, -1
3. If the lowest digit is odd but the highest digit is even, simply reversing the entire number, 1
4. Otherwise first reverse an even number to the highest, then reverse the entire number, 2

// compile: make data
// run: ./data < data.in
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#include <debug/codeforces.h>
#define debug(x...) _debug_print(#x, x);
#define Debug(x...) _debug_print_format(#x, x);
std::ifstream terminal("/dev/tty");
#define PP cerr<<"\033[1;30mpause...\e[0m",terminal.ignore();
#else
#define debug(x...)
#define Debug(x...)
#define PP
#endif
template<typename...Args> void print_(Args...args){((cout<<args<<" "),...)<<endl;}
#define rep(i,a,b) for(int i=(a);i<(int)(b);++i)
#define sz(v) ((int)(v).size())
#define print(...) print_(__VA_ARGS__);
#define FIND(a, x) ((find(a.begin(),a.end(),(x))!=a.end())?1:0)
#define cmin(x,...) x=min({(x),__VA_ARGS__})
#define cmax(x,...) x=max({(x),__VA_ARGS__})
#define INTMAX (int)(9223372036854775807)
#define INF (int)(1152921504606846976)
#define NaN (int)(0x8b88e1d0595d51d1)
#define double long double
#define int long long
#define uint unsigned long long
#define MAXN 200010

void solve() {
    string s; cin >> s;
    bool even = 0;
    rep(i, 0, sz(s)) even |= (((s[i] - '0') & 1) == 0);
    if (!even) {
        cout << -1 << endl;
        return;
    }
    if (((s[sz(s)-1] - '0') & 1) == 0) {
        cout << 0 << endl;
        return;
    }
    if (((s[0] - '0') & 1) == 0) {
        cout << 1 << endl;
        return;
    }
    cout << 2 << endl;
}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int _; cin >> _;
    while (_--) solve();

    return 0;
}

Comments

  1. 4 months ago
    2025-12-06 2:22:03

    Winningpluscasino? Sounds promising! Let’s hope it lives up to its name, eh? I’m feeling lucky tonight! Fingers crossed. Time to win at winningpluscasino

  2. 3 months ago
    2025-12-19 13:37:00

    Heard OK9Casino’s pretty rad, eh? Gonna check it out for some cheeky spins later. Hopefully, lady luck’s on my side! Check them out yourself at ok9casino.

  3. 3 months ago
    2025-12-29 6:05:10

    Hey guys, just tried out spinph7. Not bad, not bad at all! Solid selection of games and things ran pretty smoothly. I’d give it a go if you’re looking for something new. Check it out here: spinph7

  4. 1 month ago
    2026-2-17 13:54:57

    For all you baccarat fans out there, ap33baccarat is a solid option. The interface is clean, gameplay is smooth, and it’s just what you need for a quick game. Give it a shot: ap33baccarat

  5. 1 month ago
    2026-2-17 13:55:13

    Mexjoy, eh? I gave it a spin the other day. Not bad at all! The games are pretty fun and the site’s easy to navigate. Definitely worth checking out if you’re looking for something new. Check it out here: mexjoy

  6. 1 month ago
    2026-2-17 13:55:29

    Casinoradiante… sounds promising. I tried my luck there recently and it was a good time. Good selection of slots, fair bonus deals. Give it a shot if you are curious: casinoradiante!

  7. 2 weeks ago
    2026-3-04 12:19:20

    About to try out yawin. Hope to hit a big payout soon. Let’s see if it lives up to the hype! You should stop by yawin

  8. 2 weeks ago
    2026-3-04 12:19:36

    Hey guys, checked out 188jl the other day. Not bad, pretty smooth experience. Definitely worth a look if you’re looking for something new. Check it out here 188jl

  9. 2 weeks ago
    2026-3-04 12:19:51

    Yo! Just giving a shoutout to 567jl. Gave it a spin and had a decent time. Give it a try if you’re bored. Link is right here: 567jl

  10. 1 week ago
    2026-3-11 6:40:20

    Really interesting read! The focus on player experience-adapting to individual patterns-feels like the future of online casinos. I checked out bouncy balls games and their tech seems solid. Hoping for more innovation like this! 👍

  11. 5 days ago
    2026-3-16 23:27:20

    Just found this elite Filipino gaming hub! The instant GCash deposits and zero-latency slots are insane. Ready to dominate with spentime download now for real championship action!

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next