标签:scan define efi ace std 模拟 tin tor practice
//H #include <iostream> #include <algorithm> using namespace std; typedef long long ll; int main() { int n; cin >> n; int i=1; ll a[5]; for(int i=1;i<=n;i++) { for(int j=0;j<3;j++) { cin >> a[j]; } printf("Data set #%d:\n",i); printf(" Original order: %lld %lld %lld\n",a[0],a[1],a[2]); sort(a,a+3); printf(" Smallest to largest: %lld %lld %lld\n",a[0],a[1],a[2]); printf("\n"); } return 0; } //B #include <bits/stdc++.h> using namespace std; typedef long long ll; string s[3]; int main() { int t; cin >> t; string a,b; s[0]="First string is older"; s[1]="First string is younger"; s[2] = "The two strings are the same age"; cout << s[0]<<endl; for(int i=1;i<=t;i++) { cin >> a >> b; ll p[26]={0},q[26]={0}; for(int j=0;j<a.length();j++) { p[a[j]-‘a‘]++; } for(int j=0;j<b.length();j++) { q[b[j]-‘a‘]++; } int flag =0 ,bgm =0; for(int j=25;j>=0;j--) { if(p[j]>q[j]) { flag=1; break; } else if(p[j]<q[j]) { bgm =1; break; } } printf("Data set #%d: ",i); if(flag) { cout<<s[0]<<endl; } else if(bgm) { cout<<s[1]<<endl; } else{ cout<<s[2]<<endl; } printf("\n"); } } //c #include <bits/stdc++.h> using namespace std; typedef long long ll; vector<pair<int,int>>v; const int N = 1e4 +10; struct node{ ll p,q; }; map<int,int>mp; node nd[N]; int kg1[N],kg2[N]; bool cmp(node x, node y) { return x.p<y.p; } int main() { int n; cin >> n; for(int i=1;i<=n;i++) { memset(kg2,0,sizeof(kg2)); memset(kg1,0,sizeof(kg1)); memset(nd,0,sizeof(nd)); mp.clear(); int m; cin >> m; int cun =1; for(int j=1;j<=m;j++) { int a,b; scanf("%d%d",&a,&b); if(mp[a]>0) { nd[mp[a]].q+=b; } else{ mp[a] = cun; nd[cun].p = a; nd[cun].q = b; cun++; } } sort(nd,nd+cun,cmp); printf("Prime Factorization #%d:\n",i); for(int j=1;j<cun;j++) { int xy =nd[j].q; int num =0; while(xy) { xy/=10; num++; } kg1[j]=num; //printf(" %lld",nd[j].q); } //printf("\n"); for(int j=1;j<cun;j++) { int xy =nd[j].p; int num =0; while(xy) { xy/=10; num++; } kg2[j]=num; //printf("%lld%c",nd[j].p,j+1==cun?‘\n‘:‘ ‘); } for(int j=1;j<cun;j++) { for(int k=1;k<=kg2[j];k++) { printf(" "); } printf("%lld",nd[j].q); } printf("\n"); for(int j=1;j<cun;j++) { printf("%lld",nd[j].p); for(int k=1;k<=kg1[j];k++) { printf(" "); } } printf("\n"); if(i!=n) printf("\n"); } return 0; }
//G
#include<bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false); typedef long long ll; #define P 3.14159265358979 const int maxn=2e5+10; ll a[maxn],dp[maxn]; map<char,int>mp; int main(){ int t ; cin >> t; int sum=0; int tt=t; while(t--){ sum++; string s; cin >> s; cout << "Pattern "<< sum<<": "; stack<int> st; int vis[100]; memset(vis,0,sizeof(vis)); int len=s.length(); int aa[100],bb[100]; int cnta=0,cntb=0; int flag=0; for(int i=0;i<len;i++){ if(s[i]==‘a‘){ aa[++cnta]=i; continue; } if(s[i]==‘b‘){ bb[++cntb]=i; continue; } if(s[i]==‘c‘) continue; flag=1; } // cout << cnta << " " << cntb << endl; if(flag||(cnta!=cntb)) { cout<< "Still Looking." << endl; if(sum!=tt) cout << endl; continue; } int flag2=0; for(int i=0;i<len;i++){ if(s[i]==‘c‘) continue; if(s[i]==‘a‘) st.push(i); if(s[i]==‘b‘){ int flag3=0; int t=st.top(); for(int j=t+1;j<i;j++){ if(vis[j]==3) flag3=1; if(s[j]==‘c‘) flag3=1; } if(flag3==1){ for(int j=t;j<=i;j++){ vis[j]=3; } st.pop(); } else{ flag2=1; break; } } } if(flag2==1) cout<< "Still Looking." << endl; else cout << "More aliens!" << endl; if(sum!=tt) cout << endl; } return 0; }
UCF Local Programming Contest 2012(Practice)
标签:scan define efi ace std 模拟 tin tor practice
原文地址:https://www.cnblogs.com/wsxmmfby-jy/p/12610734.html