QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#646741#7695. Double Upzeyu#AC ✓224ms7796kbC++233.1kb2024-10-17 05:50:582024-10-17 05:50:58

Judging History

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

  • [2024-10-17 05:50:58]
  • 评测
  • 测评结果:AC
  • 用时:224ms
  • 内存:7796kb
  • [2024-10-17 05:50:58]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pl pair<ll, ll>
#define pi pair<int, int>
#define minpq priority_queue<ll, vector<ll>, greater<ll>>
using namespace std;

#if 1
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '['; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "]";}
void _print() {cerr << endl << flush;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "*["<<__LINE__<<"]\t"<< #x << " = "; _print(x)
#endif

const ll mod = 1e9 + 7;

template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll gcd(ll a, ll b) {if(b == 0){return a;} return gcd(b, a % b);}

__int128 read_int128() {
    string str;
    cin >> str;

    __int128 x = 0, f = 1;
    if (str[0] == '-') {
        f = -1;
        str = str.substr(1);
    }

    for (char c : str) {
        x = x * 10 + (c - '0');
    }
    return x * f;
}

ostream& operator<<(ostream& dest, __int128_t value){
    ostream::sentry s( dest );
    if (s) {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[128];
        char* d = std::end(buffer);
        do{
            -- d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) {
            -- d;
            *d = '-';
        }
        int len = end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len) {
            dest.setstate(ios_base::badbit);
        }
    }
    return dest;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<__int128_t> a(n); for (int i = 0; i < n; i ++) a[i] = read_int128();
	vector<int> b(n);
	for (int i = 0; i < n; i ++){
		for (int j = 0; j <= 100; j ++) if (a[i] & ((__int128_t)1 << j)) b[i] = j;
	}
	int dp[n + 1][n + 1]; memset(dp, 0, sizeof(dp));
	for (int i = 0; i < n; i ++) dp[i][i] = b[i];	
	for (int len = 2; len <= n; len ++){
		for (int i = 0; i + len - 1 < n; i ++){
			int j = i + len - 1;
			for (int k = 1; k < len; k ++){
				int l = i + k - 1;
				if (dp[i][l] == dp[l + 1][j]) chkmax(dp[i][j], dp[i][l] + 1);
				else chkmax(dp[i][j], max(dp[i][l], dp[l + 1][j]));
			}
		}
	}
	cout << ((__int128_t)1 << dp[0][n - 1]) << '\n';
}

详细

Test #1:

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

input:

5
4 2 2 1 8

output:

16

result:

ok single line: '16'

Test #2:

score: 0
Accepted
time: 217ms
memory: 7796kb

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

512

result:

ok single line: '512'

Test #3:

score: 0
Accepted
time: 224ms
memory: 7604kb

input:

1000
1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650...

output:

649037107316853453566312041152512

result:

ok single line: '649037107316853453566312041152512'

Test #4:

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

input:

1
1

output:

1

result:

ok single line: '1'

Test #5:

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

input:

1
2

output:

2

result:

ok single line: '2'

Test #6:

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

input:

1
4294967296

output:

4294967296

result:

ok single line: '4294967296'

Test #7:

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

input:

1
18446744073709551616

output:

18446744073709551616

result:

ok single line: '18446744073709551616'

Test #8:

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

input:

1
1267650600228229401496703205376

output:

1267650600228229401496703205376

result:

ok single line: '1267650600228229401496703205376'

Test #9:

score: 0
Accepted
time: 11ms
memory: 4212kb

input:

384
18014398509481984 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 10737418...

output:

618970019642690137449562112

result:

ok single line: '618970019642690137449562112'

Test #10:

score: 0
Accepted
time: 11ms
memory: 4228kb

input:

430
36893488147419103232 128 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248...

output:

158456325028528675187087900672

result:

ok single line: '158456325028528675187087900672'

Test #11:

score: 0
Accepted
time: 28ms
memory: 4724kb

input:

527
1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 10...

output:

158456325028528675187087900672

result:

ok single line: '158456325028528675187087900672'

Test #12:

score: 0
Accepted
time: 103ms
memory: 6208kb

input:

809
1073741824 77371252455336267181195264 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 20...

output:

19807040628566084398385987584

result:

ok single line: '19807040628566084398385987584'

Test #13:

score: 0
Accepted
time: 15ms
memory: 4372kb

input:

435
618970019642690137449562112 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 128 128 128 128 128 128 128 128 128 128 128 128 128 ...

output:

316912650057057350374175801344

result:

ok single line: '316912650057057350374175801344'

Test #14:

score: 0
Accepted
time: 124ms
memory: 6724kb

input:

857
4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 43...

output:

1267650600228229401496703205376

result:

ok single line: '1267650600228229401496703205376'

Test #15:

score: 0
Accepted
time: 84ms
memory: 6176kb

input:

765
17592186044416 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 241785163922925834941...

output:

1237940039285380274899124224

result:

ok single line: '1237940039285380274899124224'

Test #16:

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

input:

122
2097152 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 ...

output:

10141204801825835211973625643008

result:

ok single line: '10141204801825835211973625643008'

Test #17:

score: 0
Accepted
time: 22ms
memory: 4520kb

input:

491
8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 562949953421312 9444732965739290427392 9444732965739290427392 9444732965739290427392 9444732965739290427392 9444732965739290427392 94447329657392904273...

output:

1267650600228229401496703205376

result:

ok single line: '1267650600228229401496703205376'

Test #18:

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

input:

164
549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 5497558138...

output:

20282409603651670423947251286016

result:

ok single line: '20282409603651670423947251286016'