C++#include<iostream>
#include<cstdio>
#define N 50005
using namespace std;
typedef long long ll
int n,m,l[N],r[N],opt[N],node,tag[400*N],ch[400*N][2];ll c[N];
void pushdown(int cur,int l,int r)
{
if(!tag[cur])return ;
int mid=(l+r)>>1;
for(int i=0;i<=1;i++)
{
int len=(i==0)?mid-l+1:r-mid;
if(!ch[cur][i])ch[cur][i]=++node;
tag[ch[cur][i]]+=tag[cur];
size[ch[cur][i]]+=len;
}
}
void updata(int l,int r,int L,int R,int &cur)
{
if(!cur)cur=++node;
if(L<=l&&r<=R)
{
tag[cur]++;
size[cur]+=r-l+1;
return ;
}
pushdown(cur,l,r);
int mid=(l+r)>>1;
if(L<=mid)updata(l,mid,L,R,ch[cur][0]);
if(R>=mid+1)updata(mid+1,r,L,R,ch[cur][1]);
size[cur]=size[cur<<1]+size[cur<<1|1];
}
int query(int l,int r,int L,int R,int cur)
{
}
void preupdata(int l,int r,int L,int R,int pos,int cur)
{
updata(1,n,rt[cur],)
if(l==r)return ;
int mid=(l+r)>>1;
if(pos<=mid)preupdata(l,mid,L,R,pos,cur<<1);
else preupdata(mid+1,r,L,R,pos,cur<<1|1);
}
int prequery(int l,int r,int L,int R,ll js,int cur)
{
if(l==r)return
int mid=(l+r)>>1;
ll left=query(rt[cur<<1],L,R);
if(left)
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)scanf("%d%d%d%lld",&opt[N],&l[N],&r[N],&c[N]);
for(int i=1;i<=m;i++)
if(opt[i]==1)preupdata(1,n,l[i],r[i],c[i],1);
else printf("%d\n",prequery(1,n,l[i],r[i],c[i],1));
return 0;
}
C++#include<iostream>
#include<cstdio>
#define N 1005
using namespace std;
struct bian{
int to,cost,next;
}edge[N*2];
int head[N],cnt,n;
void addedge(int u,int v,int cost)
{
edge[++cnt].to=v;
edge[cnt].cost=cost;
edge[cnt].next=head[u];
head[u]=cnt;
}
int main()
{
scanf("%d",&n);
for(int x,y,z,i=1;i<=n;i++)
{
scanf("%d%d%d",&x,&y,&z);
addedge(x,y,z);
addedge(y,x,z);
}
}
C++#include<iostream>
#include<cstdio>
using namespace std;
int js=0;
int main()
{
while(true)
{js++;
system("hrddata.exe > hrd.in");
system("hrd.exe < hrd.in > hrd.out ");
system("hrdbl.exe < hrd.in > hrdbl.out ");
if(system("fc hrd.out hrdbl.out"))
{printf("WA on test %d\n",js);break;}
else printf("AC on test %d\n",js);
}
return 0;
}
C++#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<time.h>
using namespace std;
int map[32][32];
int main()
{
srand((unsigned)time(NULL));
int n=5,m=5,q=5;
cout<<n<<" "<<m<<" "<<q<<endl;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
map[i][j]=rand()%2;
cout<<map[i][j]<<" ";
}
cout<<endl;
}
for(int i=1;i<=q;i++)
{
int ex=rand()%n+1,ey=rand()%m+1;
int sx=rand()%n+1,sy=rand()%m+1;
int tx=rand()%n+1,ty=rand()%m+1;
while(!map[ex][ey])
ex=rand()%n+1,ey=rand()%m+1;
while(!map[sx][sy]||(sx==ex&&sy==ey))
sx=rand()%n+1,sy=rand()%m+1;
while(!map[tx][ty])
tx=rand()%n+1,ty=rand()%m+1;
cout<<ex<<" "<<ey<<" "<<sx<<" "<<sy<<" "<<tx<<" "<<ty<<endl;
}
system("pause");
return 0;
}
C++#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#define N 100010
using namespace std;
int n,m,q,dx[4]={0,1,-1,0},dy[4]={1,0,0,-1},cnt,dis[N];
int inqueue[N],map[32][32],ex,ey,sx,sy,tx,ty,num,tot,ans,head[N];
struct node{
int ex,ey,sx,sy,last;
};
struct bian{
int to,cost,next;
};
void addedge(int u,int v,int cost)
{
edge[++cnt].to=v;
edge[cnt].cost=cost;
edge[cnt].next=head[u];
head[u]=cnt;
}
void SPFA(int s)
{
memset(dis,0x3f,sizeof(dis));
queue <int> q;
q.push(s);dis[s]=0;
while(!q.empty())
{
int from=q.front();q.pop();
inqueue[from]=0;
for(int i=head[from];i!=0;i=edge[i].next)
{
int to=edge[i].to,cost=edge[i].cost;
if(dis[from]+cost<dis[to])
{
dis[to]=dis[from]+cost;
if(!inqueue[to])
{
inqueue[to]=1;
q.push(to);
}
}
}
}
}
void bfs(int ex,int ey,int sx,int sy)
{
}
int main()
{
cin>>n>>m>>q;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>map[i][j];
for(int i=1;i<=q;i++)
{
// memset(now,0x3f,sizeof(now));
memset(dis,-1,sizeof(dis));
cin>>ex>>ey>>sx>>sy>>tx>>ty;
bfs(ex,ey,sx,sy,-1);
cout<<ans<<endl;
/* for(maxdepth=0;maxdepth<=1000;maxdepth++)
if(dfs(ex,ey,sx,sy,0,-1)){cout<<maxdepth<<endl;break;}
if(maxdepth>=31)cout<<-1<<endl; */
}
return 0;
}
/*
10 20 5
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0
1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 0 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0
1 0 1 0 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 0
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1
1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0
6 13 3 15 1 5
3 11 5 19 10 9
1 12 4 5 9 5
5 15 6 11 3 8
1 6 7 19 3 20
3060
3482
134
1288
-1
*/