QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#54636#4184. Amusement ArcadeT3alaadl3k2olyehymn3k#AC ✓3ms3712kbC++1.7kb2022-10-09 21:59:502022-10-09 21:59:54

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-09 21:59:54]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3712kb
  • [2022-10-09 21:59:50]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define gtr(T) vector<T>,greater<T>
#define int long long
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void err(istream_iterator<string> it) { cerr << endl; }

template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int N = 2005;
int dp[N][N], n, m;
char a[N][N];

int solve(int r, int c) {
    if (r >= n or c >= m)return 0;
    int &ret = dp[r][c];
    if (~ret)return ret;
    ret = 0;
    if (a[r][c] == 'C')ret = 1;
    ret += max(solve(r + 1, c), solve(r, c + 1));
    return ret;
}

void trace(int r, int c) {
    if (r >= n or c >= m)return;
    if (solve(r + 1, c) > solve(r, c + 1)) {
        a[r][c] = '_';
        trace(r + 1, c);
    } else
        a[r][c] = '_', trace(r, c + 1);
}

signed main() {
    int n;
    cin >> n;
    vector<int> v{1, 3};
    while (v.back() <= n) {
        v.push_back(v.back() * 2 - 1);
    }
    for (auto e: v) {
        if (e > n || find(v.begin(), v.end(), n - e + 1) == v.end()) continue;
        cout << e << endl;
        exit(0);
    }
    cout << "impossible";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3692kb

input:

7

output:

3

result:

ok 

Test #2:

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

input:

15

output:

impossible

result:

ok 

Test #3:

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

input:

19

output:

3

result:

ok 

Test #4:

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

input:

2049

output:

1

result:

ok 

Test #5:

score: 0
Accepted
time: 2ms
memory: 3484kb

input:

32769

output:

1

result:

ok 

Test #6:

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

input:

536870913

output:

1

result:

ok 

Test #7:

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

input:

35184372088833

output:

1

result:

ok 

Test #8:

score: 0
Accepted
time: 2ms
memory: 3712kb

input:

2251799813685249

output:

1

result:

ok 

Test #9:

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

input:

576460752303423489

output:

1

result:

ok 

Test #10:

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

input:

1027

output:

3

result:

ok 

Test #11:

score: 0
Accepted
time: 2ms
memory: 3460kb

input:

2081

output:

33

result:

ok 

Test #12:

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

input:

34393292801

output:

33554433

result:

ok 

Test #13:

score: 0
Accepted
time: 2ms
memory: 3476kb

input:

1

output:

1

result:

ok 

Test #14:

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

input:

281543696187393

output:

68719476737

result:

ok 

Test #15:

score: 0
Accepted
time: 2ms
memory: 3540kb

input:

576460752303423491

output:

3

result:

ok 

Test #16:

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

input:

576460752336977921

output:

33554433

result:

ok 

Test #17:

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

input:

576461851815051265

output:

1099511627777

result:

ok 

Test #18:

score: 0
Accepted
time: 3ms
memory: 3696kb

input:

864691128455135233

output:

288230376151711745

result:

ok 

Test #19:

score: 0
Accepted
time: 2ms
memory: 3540kb

input:

635

output:

impossible

result:

ok 

Test #20:

score: 0
Accepted
time: 2ms
memory: 3600kb

input:

4537995

output:

impossible

result:

ok 

Test #21:

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

input:

4795018843

output:

impossible

result:

ok 

Test #22:

score: 0
Accepted
time: 3ms
memory: 3660kb

input:

5268828738869

output:

impossible

result:

ok 

Test #23:

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

input:

3859135424551273

output:

impossible

result:

ok 

Test #24:

score: 0
Accepted
time: 2ms
memory: 3536kb

input:

3

output:

1

result:

ok 

Test #25:

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

input:

63913510461995523

output:

impossible

result:

ok 

Test #26:

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

input:

341683697045680425

output:

impossible

result:

ok 

Test #27:

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

input:

999999999999999999

output:

impossible

result:

ok 

Test #28:

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

input:

5

output:

1

result:

ok 

Test #29:

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

input:

9

output:

1

result:

ok 

Test #30:

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

input:

11

output:

3

result:

ok 

Test #31:

score: 0
Accepted
time: 2ms
memory: 3540kb

input:

13

output:

5

result:

ok 

Test #32:

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

input:

17

output:

1

result:

ok