QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#37154 | #1279. Distinct Number | wyhao | Compile Error | / | / | C++ | 2.3kb | 2022-06-30 13:25:22 | 2022-06-30 13:25:25 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-06-30 13:25:25]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-06-30 13:25:22]
- 提交
answer
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=7000005;
int TT,n,t,s,rt;
bool vis[65];
struct node{
int l,r,flag;
ll sum;
}T[N];int cnt;
void change(int &p,ll x,ll y,ll l,ll r){
if(!p){
p=++cnt;
T[p].l=T[p].r=0;
T[p].sum=T[p].flag=0;
}
if(T[p].flag) return;
if(l<=x and y<=r){
T[p].flag=1;
T[p].sum=y-x+1;
return;
}
ll mid=(x+y)>>1;
if(l<=mid) change(T[p].l,x,mid,l,r);
if(mid<r) change(T[p].r,mid+1,y,l,r);
T[p].sum=T[T[p].l].sum+T[T[p].r].sum;
}
int main(){
ll x,y,l,r;
ll a,b;
scanf("%d",&TT);
while(TT--){
scanf("%d",&n);
scanf("%lld",&x);
y=x;t=0;s=0;rt=0;cnt=0;
while(y){
vis[t]=y&1;
if(y&1) s++;
y>>=1;t++;
}
y=(1<<s)-1;
// printf("%lld\n",y);
for(int i=1;i<=n;i++){
scanf("%lld%lld",&l,&r);
if(r-l+1>x){
// printf("0 %d\n",y);
change(rt,0,y,0,y);
continue;
}
a=b=0;
for(int i=t;~i;i--){
if(vis[i]){
a<<=1;
if((l>>i)&1) a++;
b<<=1;
if((r>>i)&1) b++;
}
}
// printf("%lld %lld\n",a,b);
if(a<=b) change(rt,0,y,a,b);
else change(rt,0,y,0,a),change(rt,0,y,b,y);
}
printf("%lld\n",T[rt].sum);
}
return 0;
} #include<cstdio>
using namespace std;
typedef long long ll;
const int N=5000005;
int TT,n,t,s,rt;
bool vis[65];
struct node{
int l,r,flag;
ll sum;
}T[N];int cnt;
void change(int &p,ll x,ll y,ll l,ll r){
if(!p){
p=++cnt;
T[p].l=T[p].r=0;
T[p].sum=T[p].flag=0;
}
if(T[p].flag) return;
if(l<=x and y<=r){
T[p].flag=1;
T[p].sum=y-x+1;
return;
}
ll mid=(x+y)>>1;
if(l<=mid) change(T[p].l,x,mid,l,r);
if(mid<r) change(T[p].r,mid+1,y,l,r);
T[p].sum=T[T[p].l].sum+T[T[p].r].sum;
}
int main(){
ll x,y,l,r;
ll a,b;
scanf("%d",&TT);
while(TT--){
scanf("%d",&n);
scanf("%lld",&x);
y=x;t=0;s=0;rt=0;cnt=0;
while(y){
vis[t]=y&1;
if(y&1) s++;
y>>=1;t++;
}
y=(1<<s)-1;
for(int i=1;i<=n;i++){
scanf("%lld%lld",&l,&r);
if(r-l+1>x){
change(rt,0,y,0,y);
continue;
}
a=b=0;
for(int i=t;~i;i--){
if(vis[i]){
a<<=1;
if((l>>i)&1) a++;
b<<=1;
if((r>>i)&1) b++;
}
}
if(a<=b) change(rt,0,y,a,b);
else change(rt,0,y,0,a),change(rt,0,y,b,y);
}
printf("%lld\n",T[rt].sum);
}
return 0;
}
Details
answer.code:66:3: error: stray ‘#’ in program 66 | } #include<cstdio> | ^ answer.code:66:4: error: ‘include’ does not name a type 66 | } #include<cstdio> | ^~~~~~~ answer.code:69:11: error: redefinition of ‘const int N’ 69 | const int N=5000005; | ^ answer.code:4:11: note: ‘const int N’ previously defined here 4 | const int N=7000005; | ^ answer.code:70:5: error: redefinition of ‘int TT’ 70 | int TT,n,t,s,rt; | ^~ answer.code:5:5: note: ‘int TT’ previously declared here 5 | int TT,n,t,s,rt; | ^~ answer.code:70:8: error: redefinition of ‘int n’ 70 | int TT,n,t,s,rt; | ^ answer.code:5:8: note: ‘int n’ previously declared here 5 | int TT,n,t,s,rt; | ^ answer.code:70:10: error: redefinition of ‘int t’ 70 | int TT,n,t,s,rt; | ^ answer.code:5:10: note: ‘int t’ previously declared here 5 | int TT,n,t,s,rt; | ^ answer.code:70:12: error: redefinition of ‘int s’ 70 | int TT,n,t,s,rt; | ^ answer.code:5:12: note: ‘int s’ previously declared here 5 | int TT,n,t,s,rt; | ^ answer.code:70:14: error: redefinition of ‘int rt’ 70 | int TT,n,t,s,rt; | ^~ answer.code:5:14: note: ‘int rt’ previously declared here 5 | int TT,n,t,s,rt; | ^~ answer.code:71:6: error: redefinition of ‘bool vis [65]’ 71 | bool vis[65]; | ^~~ answer.code:6:6: note: ‘bool vis [65]’ previously declared here 6 | bool vis[65]; | ^~~ answer.code:72:8: error: redefinition of ‘struct node’ 72 | struct node{ | ^~~~ answer.code:7:8: note: previous definition of ‘struct node’ 7 | struct node{ | ^~~~ answer.code:75:2: error: conflicting declaration ‘int T [7000005]’ 75 | }T[N];int cnt; | ^ answer.code:10:2: note: previous declaration as ‘node T [7000005]’ 10 | }T[N];int cnt; | ^ answer.code:75:11: error: redefinition of ‘int cnt’ 75 | }T[N];int cnt; | ^~~ answer.code:10:11: note: ‘int cnt’ previously declared here 10 | }T[N];int cnt; | ^~~ answer.code:76:6: error: redefinition of ‘void change(int&, ll, ll, ll, ll)’ 76 | void change(int &p,ll x,ll y,ll l,ll r){ | ^~~~~~ answer.code:11:6: note: ‘void change(int&, ll, ll, ll, ll)’ previously defined here 11 | void change(int &p,ll x,ll y,ll l,ll r){ | ^~~~~~ answer.code:93:5: error: redefinition of ‘int main()’ 93 | int main(){ | ^~~~ answer.code:28:5: note: ‘int main()’ previously defined here 28 | int main(){ | ^~~~ answer.code: In function ‘int main()’: answer.code:31:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 31 | scanf("%d",&TT); | ~~~~~^~~~~~~~~~ answer.code:33:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | scanf("%d",&n); | ~~~~~^~~~~~~~~ answer.code:34:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%lld",&x); | ~~~~~^~~~~~~~~~~ answer.code:44:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 44 | scanf("%lld%lld",&l,&r); | ~~~~~^~~~~~~~~~~~~~~~~~ answer.code: In function ‘int main()’: answer.code:96:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 96 | scanf("%d",&TT); | ~~~~~^~~~~~~~~~ answer.code:98:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 98 | scanf("%d",&n); | ~~~~~^~~~~~~~~ answer.code:99:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 99 | scanf("%lld",&x); | ~~~~~^~~~~~~~~~~ answer.code:108:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 108 | scanf("%lld%lld",&l,&r); | ~~~~~^~~~~~~~~~~~~~~~~~