01 额,乱搞
#include <iostream>
#include <cstdio>
using namespace std;
const int MAXN = 1000+5;
int a[MAXN], b[MAXN];
int l[MAXN], r[MAXN];
bool vis[MAXN];
int main(){
int T;
cin >> T;
while(T--) {
int N, M;
scanf("%d%d", &N, &M);
fill(vis, vis+N+1, false);
for(int i = 1; i <= N; i++) {
scanf("%d", a + i);
l[i] = r[i] = i;
}
for(int i = 1; i <= N; i++) {
scanf("%d", b + i);
}
for(int i = 0; i < M; i++) {
int x, y;
scanf("%d%d", &x, &y);
for(int j = 1; j <= N; j++) {
if (l[j] >= x && l[j] <= y) l[j] = x;
if (r[j] >= x && r[j] <= y) r[j] = y;
}
}
bool ok = true;
for(int i = 1; i <= N; i++) {
int pos = -1;
for(int j = l[i]; j <= i; j++) {
if (!vis[j] && b[j] == a[i]) {
pos = j;
break;
}
}
if (pos == -1) for(int j = i + 1; j <= r[i]; j++) {
if (!vis[j] && b[j] == a[i]) {
pos = j;
break;
}
}
if (pos == -1) {ok = false; break;}
else vis[pos] = true;
}
cout << (ok ? "Yes" : "No") << endl;
}
return 0;
}
06
解个微分方程,得出v=sqrt(2ct+v0*v0)
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=100007;
double v[N];
int main(){
//freopen("fuck.in","r",stdin);
int T,n,q,x,k;
double c,t;
scanf("%d",&T);
while (T--){
scanf("%d%lf",&n,&c);
for (int i=1;i<=n;i++)
scanf("%lf%d%d",&v[i],&x,&x);
sort(v+1,v+n+1);
scanf("%d",&q);
while(q--){
scanf("%lf%d",&t,&k);
double ans = 1.0*v[k]*v[k];
ans += 2.0*c*t;
ans = sqrt(ans);
printf("%.3lf
",ans);
}
}
return 0;
}
11
还是乱搞
#include <iostream>
#include <cstdio>
using namespace std;
const int MAXN = 100000+5;
char data[MAXN];
int main(){
int T;
cin >> T;
while(T--) {
int n;
scanf("%d", &n);
scanf("%s", data);
int cnt = 0;
bool ok = true;
for(int i = 0; i < n; i++) {
if (data[i] == '(') cnt++;
else cnt--;
if (cnt < -2){ok = false;break; }
}
if (cnt != 0) ok = false;
if (n == 2 && data[0] == '(') ok = false;
if (ok) cout << "Yes" << endl;
else cout << "No" << endl;
}
return 0;
}
08
有毒
有毒
有毒
扔个WA的代码吧,反正没人看
悬疑代码了
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=800007;
ll arr[N];
struct tree{
ll su[N],ma[N],mi[N],tag[N],set[N],size[N],ans;
int l[N],r[N],M;
inline void Tag(int t,ll x){
mi[t]+=x;
ma[t]+=x;
su[t]+=size[t]*x;
if (set[t])set[t]+=x;
else tag[t]+=x;
}
inline void Set(int t,ll x){
mi[t]=ma[t]=x;
su[t]=size[t]*x;
if (tag[t])tag[t]=0;
set[t]=x;
}
inline void down(int t){
if (tag[t]){
Tag(t<<1 ,tag[t]);
Tag(t<<1^1,tag[t]);
tag[t] = 0 ;
}
if (set[t]){
Set(t<<1 ,set[t]);
Set(t<<1^1,set[t]);
set[t] = 0 ;
}
}
inline void maintain(int t){
ma[t]=max(ma[t<<1],ma[t<<1^1]);
mi[t]=min(mi[t<<1],mi[t<<1^1]);
su[t]= su[t<<1]+su[t<<1^1] ;
}
void build(int n){
M=1; while(M<n)M<<=1; M--;
for (int i=M+1;i<=M*2+1;i++){
l[i]=r[i]=i-M;
su[i]=ma[i]=mi[i]=(i<=M+n)?(ll)arr[i-M]:0;
size[i]=1;
tag[i]=set[i]=0;
}
for (int i=M;i>=1;i--){
l[i]=l[i<<1],r[i]=r[i<<1^1];
maintain(i);
size[i]=size[i<<1]<<1;
}
}
void Add(int L,int R){
ll x;scanf("%I64d",&x);
add(1,L,R,x);
}
void add(int t,int L,int R,ll x){
if (L<=l[t]&&r[t]<=R){Tag(t,x);return;}
down(t);
int mid = (l[t] + r[t]) >> 1;
if (L<=mid)add(t<<1 ,L,R,x);
if (mid< R)add(t<<1^1,L,R,x);
maintain(t);
}
void Sqrt(int L,int R){_sqrt(1,L,R);}
void _sqrt(int t,int L,int R){
if (ma[t]==1){return;}
if (L<=l[t]&&r[t]<=R&&ma[t]==mi[t]){
Set(t,(ll)sqrt(ma[t]+0.5));
return;
}
down(t);
int mid = (l[t] + r[t]) >> 1;
if (L<=mid)_sqrt(t<<1 ,L,R);
if (mid <R)_sqrt(t<<1^1,L,R);
maintain(t);
}
ll sum(int L,int R){
ans = 0;
get(1,L,R);
return ans;
}
void get(int t,int L,int R){
if (L<=l[t]&&r[t]<=R){
ans += su[t];
return ;
}
down(t);
int mid=(l[t] + r[t]) >> 1 ;
if (L<=mid) get(t<<1 ,L,R);
if (mid< R) get(t<<1^1,L,R);
maintain(t);
}
}T;
int main(){
//freopen("fuck.in","r",stdin);
int cas,n,m,op,l,r;
scanf("%d",&cas);
while (cas--){
scanf("%d%d",&n,&m);
for (int i=1;i<=n;i++)scanf("%I64d",&arr[i]);
T.build(n);
while (m--){
scanf("%d%d%d",&op,&l,&r);
if (op==1)T.Add(l,r);
else if (op==2)T.Sqrt(l,r);
else printf("%I64d
",T.sum(l,r));
//printf("ALLsum%I64d
",T.sum(1,n));
}
}
return 0;
}