This field is really early in the morning SheShou
It had four questions, 8wa the end of the burst of mind, do not be seeking hack, hack will climb again
A2 B8 C38 (1) E1: 58 (7)
D questions feel can write, but do not have time to read. Fortunately, E finally found his mistake.
A question: see title when feeling good warm, count time, moved to
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<set> 6 #include<map> 7 #include<queue> 8 #include<vector> 9 #define mem(a,b) memset(a,b,sizeof(a)) 10 using namespace std; 11 #define ll long long 12 #define inf 0x3f3f3f3f 13 #define mod 1000000007 14 const int maxn=1e5+10; 15 int main() 16 { 17 int t; 18 scanf("%d",&t); 19 while(t--){ 20 int n,m; 21 cin>>n>>m; 22 int sum=60-m+(23-n)*60; 23 printf("%d\n",sum); 24 } 25 return 0; 26 }
Problem B: see title of the moment, and moved to the
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<set> 6 #include<map> 7 #include<queue> 8 #include<vector> 9 #define mem(a,b) memset(a,b,sizeof(a)) 10 using namespace std; 11 #define ll long long 12 #define inf 0x3f3f3f3f 13 #define mod 1000000007 14 const int maxn=1e5+10; 15 int main() 16 { 17 int t; 18 scanf("%d",&t); 19 while(t--){ 20 int n,m; 21 cin>>n>>m; 22 int zx=n/m,ge=m/2; 23 int sheng=n-zx*m; 24 if(sheng>=ge){ 25 printf("%d\n",zx*m+ge); 26 } 27 else{ 28 printf("%d\n",zx*m+sheng); 29 } 30 } 31 return 0; 32 }
Question C: This problem is most QAQ hack beg do not notice that I prayed
Question is intended: to n numbers between 1 ~ n or 0, to replace 1 ~ n 0 in not appeared, while meeting location is not equal to it in the index
Ideas: violence ......? I felt to be a hack ...... but calculated that complexity is not over
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<set> 6 #include<map> 7 #include<queue> 8 #include<vector> 9 #define mem(a,b) memset(a,b,sizeof(a)) 10 using namespace std; 11 #define ll long long 12 #define inf 0x3f3f3f3f 13 #define mod 1000000007 14 const int maxn=2e5+10; 15 int a[maxn],pos[maxn]={0},p[maxn]; 16 int main() 17 { 18 int n; 19 queue<int>q; 20 scanf("%d",&n); 21 int t=0; 22 for(int i=1;i<=n;i++){ 23 scanf("%d",&a[i]); 24 if(!a[i]){ 25 p[t++]=i; 26 } 27 else{ 28 pos[a[i]]=1; 29 } 30 } 31 for(int i=1;i<=n;i++){ 32 if(!pos[i]){q.push(i);} 33 } 34 for(int i=0;i<t-2;i++){ 35 int wei=q.front();q.pop(); 36 if(wei!=p[i]){ 37 a[p[i]]=wei; 38 } 39 else{ 40 q.push(wei); 41 wei=q.front();q.pop(); 42 a[p[i]]=wei; 43 } 44 } 45 int wei=q.front();q.pop();int wei2=q.front(); 46 if(p[t-1]!=wei && p[t-2]!=wei2){ 47 a[p[t-1]]=wei;a[p[t-2]]=wei2; 48 } 49 else{ 50 a[p[t-2]]=wei;a[p[t-1]]=wei2; 51 } 52 for(int i=1;i<=n;i++){ 53 printf(i==n?"%d\n":"%d ",a[i]); 54 } 55 return 0; 56 }
E title: This is the most I wa, most of the time spent looking for errors
Question is intended: to a n, n input number (1 ~ n), where the house number representative, who can move around a grid, or does not move, but only moved once. Asked the smallest, most can live in different houses
Ideas: reduce, expand, expand the number of occurrences consider the house once, twice, three times greater than or equal priority exam on the right, then is not moving, then a left. Narrow, met the house number of occurrences is zero skip, the encounter is not zero, four cases to consider 111,101,110,100.
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<set> 6 #include<map> 7 #include<queue> 8 #include<vector> 9 #define mem(a,b) memset(a,b,sizeof(a)) 10 using namespace std; 11 #define ll long long 12 #define inf 0x3f3f3f3f 13 #define mod 1000000007 14 const int maxn=2e5+10; 15 int a[maxn]={0},vis[maxn]={0},pos[maxn]={0},k; 16 int main() 17 { 18 int n; 19 int sum=0,ans=0; 20 scanf("%d",&n); 21 for(int i=0;i<n;i++){ 22 scanf("%d",&k); 23 pos[k]++; 24 vis[k]++; 25 } 26 for(int i=1;i<=n;i++){ 27 if(pos[i]==1){ 28 if(!a[i-1]){a[i-1]=1;} 29 else if(!a[i]){a[i]=1;} 30 else if(!a[i+1]){a[i+1]=1;} 31 } 32 else if(pos[i]==2){ 33 if(!a[i-1]){ 34 a[i-1]=1; 35 if(!a[i]){a[i]=1;} 36 else if(!a[i+1]){a[i+1]=1;} 37 } 38 else{ 39 a[i]=1; 40 a[i+1]=1; 41 } 42 } 43 else if(pos[i]>=3){ 44 a[i]=1;a[i-1]=1;a[i+1]=1; 45 } 46 } 47 for(int i=0;i<=n+1;i++){if(a[i]){sum++;}} 48 for(int i=1;i<=n;i++){ 49 if(vis[i] && vis[i+2] && vis[i+1]){ 50 ans++;i=i+2; 51 } 52 else if(vis[i] && vis[i+1] && !vis[i+2]){ 53 ans++;i=i+2; 54 } 55 else if(vis[i] && !vis[i+1] && vis[i+2]){ 56 ans++;i=i+2; 57 } 58 else if(vis[i] && !vis[i+1] && !vis[i+2]){ 59 ans++;i=i+2; 60 } 61 62 } 63 printf("%d %d\n",ans,sum); 64 return 0; 65 }
D and F and other finished final exams fix it. Hope that the end of all-too ah