提交记录 4704


用户 题目 状态 得分 用时 内存 语言 代码长度
orbitingfIea noi17a. 【NOI2017】整数 Accepted 100 361.88 ms 20884 KB C++11 1.25 KB
提交时间 评测时间
2018-07-30 11:13:04 2020-07-31 23:11:05
#include<bits/stdc++.h>
using namespace std;

int read(){
  static int x, fl; static char c;
  x=fl=0; c=getchar();
  for (;!(c>='0'&&c<='9');c=getchar()) if (c=='-') fl=1;
  for (; (c>='0'&&c<='9');c=getchar()) x=x*10+c-'0';
  return fl? -x: x;
}

int n;
#define uint unsigned int
uint a[2][1001000];
set<int>S;

void gao(int who,int p,uint v){
  for (;v;++p){
    v+=a[who][p];
    a[who][p]=v&((1<<30)-1);
    v>>=30;
    if (a[0][p]!=a[1][p]) S.insert(p);
    else S.erase(p);
  }
}

void add(int who,uint v,int p){
  int bel=p/30, las=p%30;
  gao(who,bel,(v&((1<<30-las)-1))<<las);
  gao(who,bel+1,v>>30-las);
}

int lower(int p){
  if (p<0) return 0;
  int bel=p/30, las=p%30, b=(1<<las+1)-1;
  if ((a[0][bel]&b)!=(a[1][bel]&b))
    return (a[0][bel]&b)<(a[1][bel]&b);
  set<int>::iterator it=S.upper_bound(bel-1);
  if (it==S.begin()) return 0;
  --it; return a[0][*it]<a[1][*it];
}

int cal(int p){
  int bel=p/30, las=p%30;
  int res=(a[0][bel]>>las&1)^(a[1][bel]>>las&1);
  return res^lower(p-1);
}

int main(){
  n=read(); read(); read(); read();
  int t, p, v;
  for (int cas=1;cas<=n;++cas){
    t=read();
    if (t==1){
      v=read(); p=read();
      if (v>0) add(0,v,p);
      if (v<0) add(1,-v,p);
    }else{
      p=read();
      puts(cal(p)? "1": "0");
    }
  }
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #138.19 us40 KBAcceptedScore: 4

Testcase #253.56 us44 KBAcceptedScore: 4

Testcase #3228.06 us44 KBAcceptedScore: 4

Testcase #4422.19 us48 KBAcceptedScore: 4

Testcase #5633.71 us48 KBAcceptedScore: 4

Testcase #6622.23 us64 KBAcceptedScore: 4

Testcase #71.318 ms232 KBAcceptedScore: 4

Testcase #81.148 ms68 KBAcceptedScore: 4

Testcase #94.708 ms672 KBAcceptedScore: 4

Testcase #106.533 ms396 KBAcceptedScore: 4

Testcase #117.341 ms192 KBAcceptedScore: 4

Testcase #127.211 ms1 MB + 36 KBAcceptedScore: 4

Testcase #1311.869 ms1 MB + 472 KBAcceptedScore: 4

Testcase #1436.878 ms4 MB + 132 KBAcceptedScore: 4

Testcase #1538.301 ms4 MB + 640 KBAcceptedScore: 4

Testcase #1677.986 ms8 MB + 208 KBAcceptedScore: 4

Testcase #1771.728 ms1 MB + 232 KBAcceptedScore: 4

Testcase #18131.342 ms12 MB + 288 KBAcceptedScore: 4

Testcase #19160.199 ms14 MB + 308 KBAcceptedScore: 4

Testcase #20361.88 ms18 MB + 256 KBAcceptedScore: 4

Testcase #21147.549 ms13 MB + 804 KBAcceptedScore: 4

Testcase #22138.214 ms2 MB + 244 KBAcceptedScore: 4

Testcase #23151.331 ms6 MB + 360 KBAcceptedScore: 4

Testcase #24148.201 ms2 MB + 392 KBAcceptedScore: 4

Testcase #25248.773 ms20 MB + 404 KBAcceptedScore: 4


Judge Duck Online | 评测鸭在线
Server Time: 2024-11-22 13:00:30 | Loaded in 2 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠