NOIonline记
没有做什么准备,也没什么惊喜。
自我感觉:50+100+100=250
民间数据:50+0+100=150
第二题是什么鬼啊,为啥我爆零了??好像是看错题了吗???
好吧确实理解错了,没有仔细看题面一轮冒泡排序的定义,当成每轮只换一个了TwT这毛病要改啊
T1 50pts
1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<cstring> 5 #include<queue> 6 #define rep(i,a,n) for(register int i = a;i <= n;++i) 7 using namespace std; 8 typedef long long ll; 9 10 ll read(){ 11 ll a = 0;char c = getchar(),l = c; 12 while(c < '0'||c > '9')l = c,c = getchar(); 13 while('0' <= c&&c <= '9')a = a*10+c-'0',c = getchar(); 14 if(l == '-')return -a;return a; 15 } 16 17 //head 18 19 const int Maxn = 1e5+10; 20 int t[Maxn],a[Maxn],b[Maxn],u[Maxn],v[Maxn]; 21 int T,n,m; 22 23 int main(){ 24 25 freopen("sequence.in","r",stdin); 26 freopen("sequence.out","w",stdout); 27 28 T = read(); 29 while(T--){ 30 n = read(),m = read(); 31 rep(i,1,n)a[i] = read(); 32 rep(i,1,n)b[i] = read(); 33 rep(i,1,m)t[i] = read(),u[i] = read(),v[i] = read(); 34 if(n == 2&&m == 1){ 35 if(t[1] == 1){ 36 if(u[1] == v[1]){ 37 if(u[1] == 1){ 38 if(a[2] == b[2]&&(((a[1]-b[1])&1) == 0))puts("YES"); 39 else puts("NO"); 40 } 41 else{ 42 if(a[1] == b[1]&&(((a[2]-b[2])&1) == 0))puts("YES"); 43 else puts("NO"); 44 } 45 } 46 else if((a[1]-a[2]) == (b[1]-b[2]))puts("YES"); 47 else puts("NO"); 48 } 49 else{ 50 if(u[1] == v[1]){ 51 if(a[1] == b[1]&&a[2] == b[2])puts("YES"); 52 else puts("NO"); 53 } 54 else{ 55 if((a[1]+a[2]) == (b[1]+b[2]))puts("YES"); 56 else puts("NO"); 57 } 58 } 59 } 60 else{ 61 62 } 63 } 64 return 0; 65 }
T2 0pts
1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<cstring> 5 #include<queue> 6 #define rep(i,a,n) for(register int i = a;i <= n;++i) 7 using namespace std; 8 typedef long long ll; 9 10 ll read(){ 11 ll a = 0;char c = getchar(),l = c; 12 while(c < '0'||c > '9')l = c,c = getchar(); 13 while('0' <= c&&c <= '9')a = a*10+c-'0',c = getchar(); 14 if(l == '-')return -a;return a; 15 } 16 17 const int Maxn = 2e5+10; 18 19 ll a[Maxn],p[Maxn]; 20 ll n,ans,o,x,m; 21 22 void merge_sort(int l,int r){ 23 if(l >= r)return; 24 int mid = l+r>>1,p = l,q = mid+1,cnt = 0; 25 int b[r-l+1]; 26 merge_sort(l,mid),merge_sort(mid+1,r); 27 while(p <= mid||q <= r) 28 if(p > mid||(q <= r&&a[q] < a[p])){ 29 b[cnt++] = a[q++]; 30 ans += mid-p+1; 31 } 32 else b[cnt++] = a[p++]; 33 for(int i = 0;i < cnt;i++)a[l+i] = b[i]; 34 } 35 36 int main(){ 37 38 freopen("bubble.in","r",stdin); 39 freopen("bubble.out","w",stdout); 40 41 n = read(),m = read(); 42 rep(i,1,n)a[i] = p[i] = read(); 43 merge_sort(1,n); 44 rep(i,1,m){ 45 o = read(),x = read(); 46 if(o == 1){ 47 if(p[x] < p[x+1])ans++; 48 else ans--; 49 swap(p[x],p[x+1]); 50 } 51 else printf("%lld\n",max(0ll,ans-x)); 52 } 53 return 0; 54 }
T3 100pts
1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<cstring> 5 #include<queue> 6 #define rep(i,a,n) for(register int i = a;i <= n;++i) 7 using namespace std; 8 typedef long long ll; 9 10 ll read(){ 11 ll a = 0;char c = getchar(),l = c; 12 while(c < '0'||c > '9')l = c,c = getchar(); 13 while('0' <= c&&c <= '9')a = a*10+c-'0',c = getchar(); 14 if(l == '-')return -a;return a; 15 } 16 17 int gcd(int a,int b){ 18 if(a == 0)return b; 19 return gcd(b%a,a); 20 } 21 22 const int Maxn = 2e5+10; 23 ll n,m,ans1; 24 ll a[Maxn],b[Maxn],s[Maxn]; 25 26 int main(){ 27 28 freopen("ring.in","r",stdin); 29 freopen("ring.out","w",stdout); 30 31 n = read(),m = read(); 32 rep(i,1,n)a[i] = read(); 33 34 sort(a+1,a+n+1); 35 36 rep(i,1,n-2)b[i] = a[i]*a[i+2]; 37 b[n-1] = a[n-1]*a[1],b[n] = a[n]*a[2]; 38 rep(i,1,n)s[i] = s[i-1]+b[i]; 39 40 rep(i,1,m){ 41 int k = read(); 42 if(k){ 43 int x = gcd(n,k),y = n/x; 44 ll ans = 0; 45 rep(j,1,x)ans += 1ll*a[(j-1)*y+1]*a[(j-1)*y+2]+a[j*y-1]*a[j*y] 46 +s[j*y-2]-s[(j-1)*y]; 47 cout << ans << endl; 48 } 49 else { 50 if(!ans1)rep(i,1,n)ans1 += a[i]*a[i]; 51 cout << ans1 << endl; 52 } 53 } 54 return 0; 55 }