QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722716#5117. Find MaximumTANGTANGCCWA 0ms3752kbC++141.5kb2024-11-07 20:01:012024-11-07 20:01:02

Judging History

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

  • [2024-11-07 20:01:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3752kb
  • [2024-11-07 20:01:01]
  • 提交

answer

#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define int long long
#define ld long double
#define i32 int
#define u32 unsigned int
#define i64 long long
#define u64 unsigned long long
#define u27 __int128
#define endl '\n'
#define VI vector<int>
#define VVI vector<VI>
#define rand() RANDOM(GEN)
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define CTM (cout<<"Time:"<<static_cast<double>(clock()-START_TIME)/CLOCKS_PER_SEC*1000<<"ms"<<endl)
typedef long long ll;

using namespace std;
random_device SEED;
mt19937_64 GEN(SEED());
uniform_int_distribution<u64> RANDOM(0, numeric_limits<u64>::max());
const clock_t START_TIME = clock();
int a[50],b[50];
int calc(int l,int r) {
    int x=l,y=r,nb=0;
    for (int i = 0; i < 45; ++i) {
        a[i]=l%3,b[i]=r%3;
        l/=3,r/=3;
    }
    int ctb;
    for (int i = 0; i <= 40; ++i) {
        nb+=b[i];
        if(b[i]) ctb=i;
    }
    nb=nb+ctb+1;
    if(x==y) return nb;
    int ans=nb-1;
    int pos;
    int f=0,g;
    for (int i = 40; i >= 0; --i) {
        if(!f and b[i]) f=1,g=i;
        pos=i;
        if(a[i]!=b[i]) break;
    }
    for(int i=0;i<pos;i++) {
        ans+=2-b[i];
    }
    return max({ans, nb});
}
signed main() {
#ifndef ONLINE_JUDGE
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif
    IO;
    int tt;
    cin>>tt;
    while(tt--) {
        int l,r;
        cin>>l>>r;
        cout<<calc(l,r)<<endl;
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3752kb

input:

10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

output:

3
4
4
5
4
4
5
4
5
5

result:

wrong answer 2nd numbers differ - expected: '3', found: '4'