• DLS优秀的快读板子


    //用的是freopen才能正常使用
    1
    #include<algorithm> 2 #include <iostream> 3 #include <stdlib.h> 4 #include <string.h> 5 #include <stdio.h> 6 #include <math.h> 7 #include <time.h> 8 #include <vector> 9 #include <bitset> 10 #include <queue> 11 #include <map> 12 #include <set> 13 using namespace std; 14 15 namespace IO{ 16 #define BUF_SIZE 100000 17 #define OUT_SIZE 100000 18 #define ll long long 19 //fread->read 20 21 bool IOerror=0; 22 inline char nc(){ 23 static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE; 24 if (p1==pend){ 25 p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin); 26 if (pend==p1){IOerror=1;return -1;} 27 //{printf("IO error! ");system("pause");for (;;);exit(0);} 28 } 29 return *p1++; 30 } 31 inline bool blank(char ch){return ch==' '||ch==' '||ch==' '||ch==' ';} 32 inline void read(int &x){ 33 bool sign=0; char ch=nc(); x=0; 34 for (;blank(ch);ch=nc()); 35 if (IOerror)return; 36 if (ch=='-')sign=1,ch=nc(); 37 for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0'; 38 if (sign)x=-x; 39 } 40 inline void read(ll &x){ 41 bool sign=0; char ch=nc(); x=0; 42 for (;blank(ch);ch=nc()); 43 if (IOerror)return; 44 if (ch=='-')sign=1,ch=nc(); 45 for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0'; 46 if (sign)x=-x; 47 } 48 inline void read(double &x){ 49 bool sign=0; char ch=nc(); x=0; 50 for (;blank(ch);ch=nc()); 51 if (IOerror)return; 52 if (ch=='-')sign=1,ch=nc(); 53 for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0'; 54 if (ch=='.'){ 55 double tmp=1; ch=nc(); 56 for (;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0'); 57 } 58 if (sign)x=-x; 59 } 60 inline void read(char *s){ 61 char ch=nc(); 62 for (;blank(ch);ch=nc()); 63 if (IOerror)return; 64 for (;!blank(ch)&&!IOerror;ch=nc())*s++=ch; 65 *s=0; 66 } 67 inline void read(char &c){ 68 for (c=nc();blank(c);c=nc()); 69 if (IOerror){c=-1;return;} 70 } 71 //fwrite->write 72 struct Ostream_fwrite{ 73 char *buf,*p1,*pend; 74 Ostream_fwrite(){buf=new char[BUF_SIZE];p1=buf;pend=buf+BUF_SIZE;} 75 void out(char ch){ 76 if (p1==pend){ 77 fwrite(buf,1,BUF_SIZE,stdout);p1=buf; 78 } 79 *p1++=ch; 80 } 81 void print(int x){ 82 static char s[15],*s1;s1=s; 83 if (!x)*s1++='0';if (x<0)out('-'),x=-x; 84 while(x)*s1++=x%10+'0',x/=10; 85 while(s1--!=s)out(*s1); 86 } 87 void println(int x){ 88 static char s[15],*s1;s1=s; 89 if (!x)*s1++='0';if (x<0)out('-'),x=-x; 90 while(x)*s1++=x%10+'0',x/=10; 91 while(s1--!=s)out(*s1); out(' '); 92 } 93 void print(ll x){ 94 static char s[25],*s1;s1=s; 95 if (!x)*s1++='0';if (x<0)out('-'),x=-x; 96 while(x)*s1++=x%10+'0',x/=10; 97 while(s1--!=s)out(*s1); 98 } 99 void println(ll x){ 100 static char s[25],*s1;s1=s; 101 if (!x)*s1++='0';if (x<0)out('-'),x=-x; 102 while(x)*s1++=x%10+'0',x/=10; 103 while(s1--!=s)out(*s1); out(' '); 104 } 105 void print(double x,int y){ 106 static ll mul[]={1,10,100,1000,10000,100000,1000000,10000000,100000000, 107 1000000000,10000000000LL,100000000000LL,1000000000000LL,10000000000000LL, 108 100000000000000LL,1000000000000000LL,10000000000000000LL,100000000000000000LL}; 109 if (x<-1e-12)out('-'),x=-x;x*=mul[y]; 110 ll x1=(ll)floor(x); if (x-floor(x)>=0.5)++x1; 111 ll x2=x1/mul[y],x3=x1-x2*mul[y]; print(x2); 112 if (y>0){out('.'); for (size_t i=1;i<y&&x3*mul[i]<mul[y];out('0'),++i); print(x3);} 113 } 114 void println(double x,int y){print(x,y);out(' ');} 115 void print(char *s){while (*s)out(*s++);} 116 void println(char *s){while (*s)out(*s++);out(' ');} 117 void flush(){if (p1!=buf){fwrite(buf,1,p1-buf,stdout);p1=buf;}} 118 ~Ostream_fwrite(){flush();} 119 }Ostream; 120 inline void print(int x){Ostream.print(x);} 121 inline void println(int x){Ostream.println(x);} 122 inline void print(char x){Ostream.out(x);} 123 inline void println(char x){Ostream.out(x);Ostream.out(' ');} 124 inline void print(ll x){Ostream.print(x);} 125 inline void println(ll x){Ostream.println(x);} 126 inline void print(double x,int y){Ostream.print(x,y);} 127 inline void println(double x,int y){Ostream.println(x,y);} 128 inline void print(char *s){Ostream.print(s);} 129 inline void println(char *s){Ostream.println(s);} 130 inline void println(){Ostream.out(' ');} 131 inline void flush(){Ostream.flush();} 132 #undef ll 133 #undef OUT_SIZE 134 #undef BUF_SIZE 135 }; 136 137 const int N=100005,K=6; 138 139 int n,k,id[K][N],a[N][K],b[N][K],Num[N],pos[K],val[K],Ans,Ind; 140 141 int cmp(int x,int y) 142 { 143 return a[x][Ind]<a[y][Ind]; 144 } 145 146 void solve() 147 { 148 IO::read(n);IO::read(k); 149 for(int i=1;i<=n;i++) 150 Num[i]=0; 151 for(int i=1;i<=k;i++) 152 IO::read(val[i]),pos[i]=1; 153 for(int i=1;i<=n;i++) 154 { 155 for(int j=1;j<=k;j++) 156 IO::read(a[i][j]); 157 for(int j=1;j<=k;j++) 158 IO::read(b[i][j]); 159 } 160 for(Ind=1;Ind<=k;Ind++) 161 { 162 for(int i=1;i<=n;i++) 163 id[Ind][i]=i; 164 sort(id[Ind]+1,id[Ind]+n+1,cmp); 165 } 166 Ans=0; 167 while(1) 168 { 169 int last=Ans; 170 for(int i=1;i<=k;i++) 171 { 172 while(pos[i]<=n&&a[id[i][pos[i]]][i]<=val[i]) 173 { 174 int t=id[i][pos[i]]; 175 Num[t]++; 176 if(Num[t]==k) 177 { 178 Ans++; 179 for(int j=1;j<=k;j++) 180 val[j]+=b[t][j]; 181 } 182 pos[i]++; 183 } 184 } 185 if(Ans==last) 186 break; 187 } 188 IO::println(Ans); 189 for(int i=1;i<=k;i++) 190 IO::print(val[i]),IO::print(i!=k?' ':' '); 191 } 192 193 int main() 194 { 195 int t;cin>>t; 196 while(t--) 197 solve(); 198 return 0; 199 }
  • 相关阅读:
    IoC~MVC3+EF+Autofac实现松耦合的系统架构 [转载]
    Ioc容器Autofac系列 向导
    依赖注入框架Autofac的简单使用 转载
    学 Win32 汇编[30] 条件及循环伪指令: .IF、.WHILE、.REPEAT 等
    学 Win32 汇编[31] 结构与联合
    在 API 函数中使用 PChar 参数的几种方法
    关于 "高位" 与 "低位" 回复 "Lovemit" 的问题
    如何把类中的方法做参数 回复 "林Lin☆☆" 的问题
    一个拼图工具的制作思路 回复 "AlwaysBug" 的问题
    简单的 "双缓冲" 绘图的例子 回复 "TookiQ" 的问题
  • 原文地址:https://www.cnblogs.com/TheStuckedCat/p/9474176.html
Copyright © 2020-2023  润新知