QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#674100#7183. PasswordRezhou#AC ✓1ms3708kbC++233.1kb2024-10-25 13:51:152024-10-25 13:51:15

Judging History

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

  • [2024-10-25 13:51:15]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3708kb
  • [2024-10-25 13:51:15]
  • 提交

answer

#include <bits/stdc++.h>
#define x first
#define y second
#define int long long
#define double long double

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef pair<int, pair<int, int>> pip;
typedef const double* (*p_fun)(const double*, int);
const LL N = 2e5 + 10, M = 2e3 + 10, mod = 1e9 + 7, LLF = 1e15,
null = 0x3f3f3f3f3f3f3f;

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T, typename... Args>
bool chmax(T& a, const T& b, const Args &...args) {
    bool updated = chmax(a, b);
    return chmax(a, args...) || updated;
}
template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T, typename... Args>
bool chmin(T& a, const T& b, const Args &...args) {
    bool updated = chmin(a, b);
    return chmin(a, args...) || updated;
}
class UnionFind {
public:
    vector<int> parent;
    vector<int> size;
    int n;
    // 当前连通分量数目
    int setCount;

public:
    UnionFind(int _n) : n(_n), setCount(_n), parent(_n), size(_n, 1) {
        iota(parent.begin(), parent.end(), 0);
    }

    int find(int x) { return parent[x] == x ? x : parent[x] = find(parent[x]); }

    bool merge(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (size[x] < size[y]) swap(x, y);
        parent[y] = x;
        size[x] += size[y];
        --setCount;
        return true;
    }

    bool connected(int x, int y) {
        x = find(x);
        y = find(y);
        return x == y;
    }
};
int qmi(int a, int b) {
    int res = 1;
    a %= mod;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }

    return res;
}
int sqrt(int x) {
    int l = 0, r = 3e9;  // LLONG_MAX
    while (l < r) {
        int mid = (l + r + 1) >> 1;
        if (mid * mid > x)
            r = mid - 1;  // 向下取整
        else
            l = mid;
    }
    return r;
}

int f[N][2];
int n, c, a[N];
vector<int> v[N];

void dfs(int u, int fa) {
    f[u][1] = a[u];
    for (auto& it : v[u]) {
        if (it == fa) continue;
        dfs(it, u);
        f[u][0] += max(f[it][0], f[it][1]);
        f[u][1] += max(f[it][0], f[it][1] - 2 * c);
    }
}

static inline void solve() {
    int n;
    cin >> n;

    int ans = 0;
    /*if (n & 1) ans = (n + 1) / 2 / 3 + n / 2 / 3 + (n / 2 % 3 != 0) + ((n + 1) / 2 % 3 != 0);
    else ans = n / 2 / 3 + n / 2 / 3 + (n / 2 % 3 != 0) * 2;*/

    for (int i = ((n + 1) / 2) - 3; i >= 1; i -= 3) ans++;
    for (int i = ((n + 1) / 2) + (n % 2 == 0) + 3; i <= n; i += 3) ans++;
    ans++;
    if (n % 2 == 0) ans++;

    cout << ans << ' ' << n << endl;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << unitbuf;
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3648kb

input:

1

output:

1 1

result:

ok single line: '1 1'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3636kb

input:

2

output:

2 2

result:

ok single line: '2 2'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

3

output:

1 3

result:

ok single line: '1 3'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

10

output:

4 10

result:

ok single line: '4 10'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3572kb

input:

5

output:

1 5

result:

ok single line: '1 5'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

6

output:

2 6

result:

ok single line: '2 6'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3560kb

input:

7

output:

3 7

result:

ok single line: '3 7'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

8

output:

4 8

result:

ok single line: '4 8'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3700kb

input:

9

output:

3 9

result:

ok single line: '3 9'

Test #10:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

4

output:

2 4

result:

ok single line: '2 4'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

9484

output:

3162 9484

result:

ok single line: '3162 9484'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

18500

output:

6168 18500

result:

ok single line: '6168 18500'

Test #13:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

52029

output:

17343 52029

result:

ok single line: '17343 52029'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

74707

output:

24903 74707

result:

ok single line: '24903 74707'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

114210

output:

38070 114210

result:

ok single line: '38070 114210'

Test #16:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

124079

output:

41359 124079

result:

ok single line: '41359 124079'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

140227

output:

46743 140227

result:

ok single line: '46743 140227'

Test #18:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

149321

output:

49773 149321

result:

ok single line: '49773 149321'

Test #19:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

158606

output:

52870 158606

result:

ok single line: '52870 158606'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

178985

output:

59661 178985

result:

ok single line: '59661 178985'

Test #21:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

203822

output:

67942 203822

result:

ok single line: '67942 203822'

Test #22:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

211113

output:

70371 211113

result:

ok single line: '70371 211113'

Test #23:

score: 0
Accepted
time: 1ms
memory: 3688kb

input:

211702

output:

70568 211702

result:

ok single line: '70568 211702'

Test #24:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

239252

output:

79752 239252

result:

ok single line: '79752 239252'

Test #25:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

251157

output:

83719 251157

result:

ok single line: '83719 251157'

Test #26:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

268701

output:

89567 268701

result:

ok single line: '89567 268701'

Test #27:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

292633

output:

97545 292633

result:

ok single line: '97545 292633'

Test #28:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

355864

output:

118622 355864

result:

ok single line: '118622 355864'

Test #29:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

385320

output:

128440 385320

result:

ok single line: '128440 385320'

Test #30:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

414180

output:

138060 414180

result:

ok single line: '138060 414180'

Test #31:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

447973

output:

149325 447973

result:

ok single line: '149325 447973'

Test #32:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

462908

output:

154304 462908

result:

ok single line: '154304 462908'

Test #33:

score: 0
Accepted
time: 1ms
memory: 3628kb

input:

473412

output:

157804 473412

result:

ok single line: '157804 473412'

Test #34:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

511511

output:

170503 511511

result:

ok single line: '170503 511511'

Test #35:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

539439

output:

179813 539439

result:

ok single line: '179813 539439'

Test #36:

score: 0
Accepted
time: 1ms
memory: 3560kb

input:

586698

output:

195566 586698

result:

ok single line: '195566 586698'

Test #37:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

673221

output:

224407 673221

result:

ok single line: '224407 673221'

Test #38:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

683861

output:

227953 683861

result:

ok single line: '227953 683861'

Test #39:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

711682

output:

237228 711682

result:

ok single line: '237228 711682'

Test #40:

score: 0
Accepted
time: 1ms
memory: 3628kb

input:

727899

output:

242633 727899

result:

ok single line: '242633 727899'

Test #41:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

738039

output:

246013 738039

result:

ok single line: '246013 738039'

Test #42:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

754671

output:

251557 754671

result:

ok single line: '251557 754671'

Test #43:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

815233

output:

271745 815233

result:

ok single line: '271745 815233'

Test #44:

score: 0
Accepted
time: 1ms
memory: 3636kb

input:

843192

output:

281064 843192

result:

ok single line: '281064 843192'

Test #45:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

898513

output:

299505 898513

result:

ok single line: '299505 898513'

Test #46:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

955601

output:

318533 955601

result:

ok single line: '318533 955601'

Test #47:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

967629

output:

322543 967629

result:

ok single line: '322543 967629'

Test #48:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

990687

output:

330229 990687

result:

ok single line: '330229 990687'

Test #49:

score: 0
Accepted
time: 1ms
memory: 3580kb

input:

999999

output:

333333 999999

result:

ok single line: '333333 999999'

Test #50:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

1000000

output:

333334 1000000

result:

ok single line: '333334 1000000'

Extra Test:

score: 0
Extra Test Passed