QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#218450#7109. Traveling on the Axisucup-team992AC ✓4ms3588kbC++173.1kb2023-10-18 12:14:182023-10-18 12:14:19

Judging History

你现在查看的是最新测评结果

  • [2023-10-18 12:14:19]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:3588kb
  • [2023-10-18 12:14:18]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define ar array
#define ll long long
typedef int uci;
#define int long long
#define F first
#define S second
typedef complex<double> cd;

seed_seq seq{
    (uint64_t) chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count(),
    (uint64_t) __builtin_ia32_rdtsc(),
    (uint64_t) (uintptr_t) make_unique<char>().get()
};
mt19937 rng(seq);
// mt19937_64 lrng(seq);

struct debugger{
    template <typename T>
    debugger& operator<<(T &a){
        #ifdef DEBUG
            cerr << a;
        #endif
        return *this;
    }
    template <typename T>
    debugger& operator<<(T &&a){
        #ifdef DEBUG
            cerr << a;
        #endif
        return *this;
    }
} deb;

const double PI = acos(-1.0);
const int MAX_N = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;

//! function insert

//THINK FIRST, CODE SECOND
//DON'T GET STUCK ON ONE STRATEGY
//CALM DOWNNN FOR ONCE IN YOUR LIFE
//REDUCE
//COUGH E??!?!?!! O.O
//uwu i see you ryan

void solve() {
    ar<int, 2> amt{};
    int out{};
    string s;
    cin >> s;
    int n = s.size();
    for(int i = n-1; i >= 0; --i){
        int fromend = n-i;
        ar<int, 2> ne = amt;
        if(s[i] == '0'){
            if(s[i+1] == '0'){
                ne[0] = amt[0] + 2*fromend;
                ne[1] = amt[0]+fromend;
            }else{
                ne[0] = amt[1] + 2*fromend;
                ne[1] = fromend + amt[1];
            }
        }else{
            if(s[i+1] == '0'){
                ne[1] = amt[1] + fromend;
                ne[0] = amt[1]+2*fromend;
            }else{
                ne[0] = amt[0] + 2*fromend;
                ne[1] = fromend + amt[0];
            }
        }
        if(s[i] == '0'){
            out += ne[0];
        }else if(s[i] == '1'){
            out += ne[1];
        }
        amt.swap(ne);
    }
    cout << out << '\n';
}

uci main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int tc; cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}

/*
    random number generator stuff
    num = rng(); gives integer number
    num = uniform_int_distribution<int>(a, b)(rng); -> bounds [a, b]
    num = uniform_real_distribution<double>(a, b)(rng); -> bounds [a, b)
    can also instantiate distributions and call on generator:
    uniform_int_distribution<int> thing(a, b);
    num = thing(rng);
*/
// struct custom_hash {
//     static uint64_t splitmix64(uint64_t x) {
//         // http://xorshift.di.unimi.it/splitmix64.c
//         x += 0x9e3779b97f4a7c15;
//         x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//         x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//         return x ^ (x >> 31);
//     }
//     size_t operator()(uint64_t x) const {
//         static const uint64_t FIXED_RANDOM = lrng();
//         return splitmix64(x + FIXED_RANDOM);
//     }
// };

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3440kb

input:

3
101
011
11010

output:

12
15
43

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 4ms
memory: 3588kb

input:

6107
1010101
010110100110101
1010
1010101010010101010
101011
0101101011010101010
0101101011
11011010101
010
1011010
10110101010101010100
010101010110101
10101010101011
0101010101010101011
00101010011000
1010101010010110110
01010101001010101010
101010101010101
100100101010101010
01
011
0101010100101
...

output:

96
889
24
1515
69
1567
279
345
14
106
1702
791
621
1447
764
1615
1755
736
1333
6
15
542
44
1689
1515
140
833
497
596
24
1640
694
462
30
425
14
1041
1446
96
504
124
75
560
970
771
945
6
1
321
137
786
720
206
769
46
103
225
74
554
2
100
529
260
207
197
2
197
1041
140
857
207
1
74
1604
41
343
1041
14
1...

result:

ok 6107 lines

Extra Test:

score: 0
Extra Test Passed