QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#609277#9427. Collect the CoinsYzm007Compile Error//C++141.7kb2024-10-04 11:44:452024-10-04 11:44:45

Judging History

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

  • [2024-11-06 15:56:27]
  • hack成功,自动添加数据
  • (/hack/1139)
  • [2024-10-04 11:44:45]
  • 评测
  • [2024-10-04 11:44:45]
  • 提交

answer

#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define pb push_back
#define dbg(x) cerr<<(#x)<<":"<<x<<" ";
#define dbg2(x) cerr<<(#x)<<":"<<x<<endl;
#define SZ(a) (int)(a.size())
#define sci(a) scanf("%d",&(a))
#define pt(a) printf("%d",a);
#define pte(a) printf("%d\n",a)
#define ptlle(a) printf("%lld\n",a)
#define debug(...) fprintf(stderr, __VA_ARGS__)
const int N=1e6+10;
const ll INF=1e9;
int t,n,c,x[N];
P a[N];
bool can(ll p,ll l,ll r,ll d){
    return l-d<=p && p<=r+d;
}
bool ok(ll v){
    int p=1;
    ll l=1,r=INF;
    rep(i,2,n){
        ll T=a[i].fi-a[p].fi,d=T*v;
        bool x=can(a[i].se,a[p],a[p],d),y=can(a[i].se,l,r,d);
        if(x && y){
            l=min(l-d,a[p].se-d);
            r=max(r+d,a[p].se+d);
        }
        else if(x){
            l=l-d;
            r=r+d;
        }
        else if(y){
            l=a[p].se-d;
            r=a[p].se+d;
        }
        else{
            return 0;
        }
        p=i;
        l=max(1ll,l);
        r=min(INF,r);
    }
    return 1;
}
ll sol(){
    sci(n);
    rep(i,1,n){
        scanf("%lld%lld",&a[i].fi,&a[i].se);
    }
    ll l=0,r=INF;
    while(l<=r){
        ll mid=(l+r)/2;
        if(ok(mid))r=mid-1;
        else l=mid+1;
    }
    if(l>INF)return -1;
    return l;
}
int main(){
    sci(t);
    while(t--){
        ptlle(sol());
    }
    return 0;
}

詳細信息

answer.code: In function ‘bool ok(ll)’:
answer.code:37:31: error: cannot convert ‘P’ {aka ‘std::pair<long long int, long long int>’} to ‘ll’ {aka ‘long long int’}
   37 |         bool x=can(a[i].se,a[p],a[p],d),y=can(a[i].se,l,r,d);
      |                            ~~~^
      |                               |
      |                               P {aka std::pair<long long int, long long int>}
answer.code:29:18: note:   initializing argument 2 of ‘bool can(ll, ll, ll, ll)’
   29 | bool can(ll p,ll l,ll r,ll d){
      |               ~~~^
answer.code:38:17: error: ‘y’ was not declared in this scope
   38 |         if(x && y){
      |                 ^
answer.code: In function ‘ll sol()’:
answer.code:20:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 | #define sci(a) scanf("%d",&(a))
      |                ~~~~~^~~~~~~~~~~
answer.code:60:5: note: in expansion of macro ‘sci’
   60 |     sci(n);
      |     ^~~
answer.code:62:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   62 |         scanf("%lld%lld",&a[i].fi,&a[i].se);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:20:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 | #define sci(a) scanf("%d",&(a))
      |                ~~~~~^~~~~~~~~~~
answer.code:74:5: note: in expansion of macro ‘sci’
   74 |     sci(t);
      |     ^~~