NEERC 2014 填坑计划(7 / 12)
7/12
已弃
A
简单贪心
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#include<set> #include<map> #include<cmath> #include<ctime> #include<queue> #include<cstdio> #include<vector> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define mod 1000000007 #define inf 1000000000 #define eps 1e-10 #define ll long long using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n,m; int main() { freopen("alter.in", "r", stdin); freopen("alter.out", "w", stdout); n=read();m=read(); printf("%d\n",n/2+m/2); for(int i=2;i<=n;i+=2) printf("%d %d %d %d\n",i,1,i,m); for(int i=2;i<=m;i+=2) printf("%d %d %d %d\n",1,i,n,i); return 0; } |
B
按B/A排序后贪心
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
#include<set> #include<map> #include<cmath> #include<ctime> #include<queue> #include<cstdio> #include<vector> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define mod 1000000007 #define inf 1000000000 #define eps 1e-10 #define ll long long using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n,A,B; double ans[100005]; struct data{ int g,a,b; int id; }a[100005]; bool operator<(data a,data b){ return (double)a.a/a.b>(double)b.a/b.b; } int main() { freopen("burrito.in","r",stdin); freopen("burrito.out","w",stdout); n=read();A=read();B=read(); for(int i=1;i<=n;i++) a[i].g=read(),a[i].a=read(),a[i].b=read(),a[i].id=i; sort(a+1,a+n+1); double t1=0,t2=0; for(int i=1;i<=n;i++) if(a[i].a) { if(a[i].b)ans[a[i].id]=min((B-t2)/a[i].b,(double)a[i].g); else ans[a[i].id]=a[i].g; t1+=a[i].a*ans[a[i].id]; t2+=a[i].b*ans[a[i].id]; } if(t1<A)puts("-1 -1"); else { printf("%.10lf %.10lf\n",t1,t2); for(int i=1;i<=n;i++) printf("%.10lf ",ans[i]); } return 0; } |
E
写的题解被吞了。。。奇怪的随机化直接看代码好了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
#include<cmath> #include<ctime> #include<cstdio> #include<vector> #include<bitset> #include<cstring> #include<iostream> #include<algorithm> #define ll long long #define mod 1000000009 #define inf 1000000000 using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n; int getint(char a) { if(a=='R')return 0; if(a=='P')return 1; return 2; } char getchar(int a) { if(a==0)return 'R'; if(a==1)return 'P'; return 'S'; } struct data{ int c,to[3]; }fsm[105],a[50005]; int main() { freopen("epic.in","r",stdin); freopen("epic.out","w",stdout); srand(123); n=read(); char ch[2]; for(int i=1;i<=n;i++) { scanf("%s",ch+1); fsm[i].c=getint(ch[1]); for(int j=0;j<3;j++) fsm[i].to[j]=read(); } int c=50000/n; for(int i=1;i<=n;i++) for(int j=0;j<c;j++) { int cur=n*j+i,nxt=(j+1)%c; for(int k=0;k<3;k++) a[cur].to[k]=nxt*n+rand()%n+1; a[cur].c=(fsm[i].c+1)%3; a[cur].to[fsm[i].c]=j*n+fsm[i].to[a[cur].c]; } printf("%d\n",c*n); for(int i=1;i<=c*n;i++) { printf("%c ",getchar(a[i].c)); for(int j=0;j<3;j++) printf("%d ",a[i].to[j]); puts(""); } return 0; } |
F
主要是读题上的困难,得出每个文件的二进制串,用bitset判包含
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
#include<cmath> #include<cstdio> #include<vector> #include<bitset> #include<cstring> #include<iostream> #include<algorithm> #define ll long long #define mod 1000000009 using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n,m,f,q; int a[105]; string t; bitset<1005>b[1005],c[1005]; vector<int>ans; int getint(char a) { if('0'<=a&&a<='9')return a-'0'; return a-'a'+10; } int main() { freopen("filter.in","r",stdin); freopen("filter.out","w",stdout); m=read();f=read(); for(int i=0;i<f;i++)a[i]=read(); n=read(); for(int i=0;i<n;i++) { cin>>t; for(int j=0;j<t.length();j++) for(int k=0;k<4;k++) if((1<<k)&getint(t[j])) b[i][j*4+k]=1; } q=read(); for(int i=1;i<=q;i++) { ll t=read(); for(int j=0;j<f;j++) c[i][t*a[j]%m]=1; } for(int i=0;i<n;i++) for(int j=1;j<=q;j++) if((b[i]&c[j])==c[j]) { ans.push_back(i); break; } printf("%lu ",ans.size()); for(int i=0;i<ans.size();i++) printf("%d ",ans[i]); return 0; } |
I
将出现次序作为权,发现合法状态是一个递增序列拼上递减序列
然后就是dp啦
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
#include<cmath> #include<cstdio> #include<vector> #include<bitset> #include<cstring> #include<iostream> #include<algorithm> #define ll long long #define mod 1000000009 #define inf 1000000000 using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n,ans; int a[200005],d[200005],g[200005],f[200005]; void solve(int *dp) { for(int i=1;i<=n;i++)f[i]=inf; for(int i=1;i<=n;i++) { int x=lower_bound(f+1,f+n+1,a[i])-f; f[x]=a[i];dp[i]=x; } } int main() { freopen("improvements.in","r",stdin); freopen("improvements.out","w",stdout); n=read(); for(int i=1;i<=n;i++) { int x=read();a[x]=i; } solve(d); reverse(a+1,a+n+1); solve(g); for(int i=1;i<=n;i++) ans=max(ans,d[i]+g[n-i+1]-1); printf("%d\n",ans); return 0; } |
J
搜索可过,因为不合法状态极多
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
#include<set> #include<map> #include<cmath> #include<ctime> #include<queue> #include<cstdio> #include<vector> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define mod 1000000007 #define inf 1000000000 #define eps 1e-10 #define ll long long using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n,len; char a[205]; vector<int>q; bool mark[205],flag; void dfs(int x) { if(flag)return; if(x==len+1) { for(int i=0;i<q.size();i++) printf("%d ",q[i]); flag=1; return; } int t=a[x]-'0'; if(!t)return; if(!mark[t]) { q.push_back(t); mark[t]=1; dfs(x+1); mark[t]=0; q.pop_back(); } if(x==len)return; t=t*10+a[x+1]-'0'; if(t<=n&&!mark[t]) { q.push_back(t); mark[t]=1; dfs(x+2); mark[t]=0; q.pop_back(); } } int main() { freopen("joke.in","r",stdin); freopen("joke.out","w",stdout); scanf("%s",a+1); len=n=strlen(a+1); if(n<=9) { for(int i=1;i<=n;i++)printf("%d ",a[i]-'0'); } else { n=9+(n-9)/2; dfs(1); } return 0; } |
K
简单模拟
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
#include<set> #include<map> #include<cmath> #include<ctime> #include<queue> #include<cstdio> #include<vector> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define mod 1000000007 #define inf 1000000000 #define eps 1e-10 #define ll long long using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n,m; int a[1005],b[1005],f[1005]; int x,y,t; int cal(int id,int t) { if(f[id])t+=(b[id]-a[id]); int p=(b[id]-a[id])*2; t%=p; if(t<p/2)return a[id]+t; else return a[id]+p-t; } int main() { freopen("knockout.in","r",stdin); freopen("knockout.out","w",stdout); n=read();m=read(); for(int i=1;i<=n;i++) { a[i]=read(),b[i]=read(); if(a[i]>b[i]) { f[i]=1; swap(a[i],b[i]); } } for(int i=1;i<=m;i++) { int ans=0; x=read(),y=read(),t=read(); for(int j=1;j<=n;j++) if(x<=cal(j,t)&&cal(j,t)<=y)ans++; printf("%d\n",ans); } return 0; } |
E的代码挂了
Orz