QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#744734#9738. Make It Divisibleucup-team073WA 0ms3776kbC++203.4kb2024-11-13 23:05:562024-11-13 23:06:04

Judging History

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

  • [2024-11-27 18:44:44]
  • hack成功,自动添加数据
  • (/hack/1263)
  • [2024-11-14 09:10:13]
  • hack成功,自动添加数据
  • (/hack/1178)
  • [2024-11-13 23:06:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3776kb
  • [2024-11-13 23:05:56]
  • 提交

answer

#include<bits/stdc++.h>
#ifdef LOCAL
#define debug(...) printf(__VA_ARGS__)
#define edebug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#define edebug(...)
#endif
#define int ll
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define nrep(i, x, y) for(int i = x; i >= y; --i)
#define ll long long
#define pii std::pair<int,int>
#define pb emplace_back
#define fi first
#define se second
template <class T> 
inline void ckmax(T &a, T b) {
  if(a < b) a = b;
}
template <class T> 
inline void ckmin(T &a, T b) {
  if(a > b) a = b;
}
auto rt_YES = []{puts("YES");};
auto rt_Yes = []{puts("Yes");};
auto rt_NO = []{puts("NO");};
auto rt_No = []{puts("No");};
namespace IO {
#define isdigit(x) (x >= '0' && x <= '9')
  inline char gc() {
    return getchar();
  }
  inline bool blank(char ch) {
    return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
  }
  template <class T>
  inline void read(T &x) {
    double tmp = 1;
    bool sign = 0;
    x = 0;
    char ch = gc();
    for(; !isdigit(ch); ch = gc())
      if(ch == '-') sign = 1;
    for(; isdigit(ch); ch = gc())
      x = x * 10 + (ch - '0');
    if(ch == '.')
      for(ch = gc(); isdigit(ch); ch = gc())
        tmp /= 10.0, x += tmp * (ch - '0');
    if(sign) x = -x;
  }
  inline void read(char *s) {
    char ch = gc();
    for(; blank(ch); ch = gc());
    for(; !blank(ch); ch = gc())
      *s++ = ch;
    *s = 0;
  }
  inline void read(char &c) {
    for(c = gc(); blank(c); c = gc());
  }
  inline void push(const char &c) {
    putchar(c);
  }
  template <class T>
  inline void print(T x) {
    if(x < 0) {
      x = -x;
      push('-');
    }
    static T sta[35];
    T top = 0;
    do {
      sta[top++] = x % 10;
      x /= 10;
    } while(x);
    while(top)
      push(sta[--top] + '0');
  }
  template <class T>
  inline void print(T x, char lastChar) {
    print(x);
    push(lastChar);
  }
}
using namespace IO;

int a[50010],ls[50010],rs[50010],stk[50010],n;
bool check(int x){
  rep(i,1,n){
    if(ls[i]&&(a[i]+x)%(a[ls[i]]+x))return 0;
    if(rs[i]&&(a[i]+x)%(a[rs[i]]+x))return 0;
  }
  debug("%lld\n",x);
  return 1;
}
void solve(){
  int x;read(n),read(x);
  int top=0;stk[0]=0;
  rep(i,1,n)ls[i]=rs[i]=0;
  rep(i,1,n){
    read(a[i]);
    int k=top;
    while(k>0&&a[stk[k]]<a[i])--k;
    if(k)rs[stk[k]]=i;
    if(k!=top)ls[i]=stk[k+1];
    top=k;
    stk[++top]=i;
  }
  int flag=0;
  rep(i,2,n)if(a[i]!=a[1])flag=1;
  if(!flag){
    print(x,' '),print((x+1)*x/2,'\n');
    return;
  }
  rep(i,1,n)debug("%lld %lld\n",ls[i],rs[i]);
  rep(i,1,n){
    int X=a[i],Y=0;
    if(ls[i]&&a[ls[i]]!=a[i])Y=a[ls[i]];
    else if(rs[i]&&a[rs[i]]!=a[i])Y=a[rs[i]];
    else continue;
    int ans=0,T=X-Y,res=0;
    // debug("%lld %lld\n",X,Y);
    for(int j=1;j*j<=T;++j)if(T%j==0){
      if(j-Y<=x&&j-Y>0&&check(j-Y))ans+=(j-Y),++res;
      if(T/j-Y<=x&&T/j-Y>0&&j*j!=T&&check(T/j-Y))ans+=(T/j-Y),++res;
    }
    print(res,' '),print(ans,'\n');
    break;
  }
}

signed main() {
  clock_t c1 = clock();
#ifdef LOCAL
  freopen("in.in", "r", stdin);
  freopen("out.out", "w", stdout);
#endif
//------------------------------------------------------------------

  int t;read(t);while(t--)solve();

//------------------------------------------------------------------
end:
  std::cerr << "Time : " << clock() - c1 << " ms" << std::endl;
  return 0;
}

詳細信息

Test #1:

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

input:

3
5 10
7 79 1 7 1
2 1000000000
1 2
1 100
1000000000

output:

3 8
0 0
100 5050

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3776kb

input:

4
201 1000000000
1 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5...

output:

1 1
1 1
1 1
1 1

result:

wrong answer 1st lines differ - expected: '0 0', found: '1 1'