7/12

# Alter Board

#include <iostream>
#include <cstring>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;

#define PI acos(-1.0)
#define LL long long
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define mp make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "wb", stdout)
#define scan(x) scanf("%d", &x)
#define scan2(x, y) scanf("%d%d", &x, &y)
#define scan3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sqr(x) (x) * (x)
#define For(i,n) for(int i=1;i<=n;i++)

int main() {
int n,m;

while(scanf("%d%d",&n,&m)==2)
{
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 j=2;j<=m;j+=2) printf("%d %d %d %d\n",1,j,n,j);
}

return 0;
}

# Burrito King

b i /a i  $b_i/a_i$排序，从小到大贪心取

#include <iostream>
#include <cstring>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;

#define PI acos(-1.0)
#define LL long long
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define mp make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "wb", stdout)
#define scan(x) scanf("%d", &x)
#define scan2(x, y) scanf("%d%d", &x, &y)
#define scan3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sqr(x) (x) * (x)
#define For(i,n) for(int i=1;i<=n;i++)

const int maxn = 100005;

int n;
int A, B;
double res[maxn];

struct Node {
int a, b, g;
int id;
double jud;
}num[maxn];

bool operator < (const Node &p, const Node &q)
{
return p.jud < q.jud;
}

int main() {
while (scanf("%d %d %d", &n, &A, &B) != EOF) {
for (int i = 0; i < n; i++) {
scanf("%d %d %d", &num[i].g, &num[i].a, &num[i].b);
num[i].id = i;
if (num[i].b == 0)
num[i].jud = 0.0;
else
if (num[i].a == 0)
num[i].jud = 1e30;
else
num[i].jud = num[i].b * 1.0 / num[i].a;
}
sort(num, num + n);
double tA = 0.0, tB = 0.0;
memset(res, 0, sizeof(res));
for (int i = 0; i < n; i++) {
if (1.0 * num[i].g * num[i].b + tB > B) {
res[num[i].id] = (1.0 * B - tB) / num[i].b;
tB = B;
tA += 1.0 * num[i].a * res[num[i].id];
break;
} else {
res[num[i].id] = num[i].g;
tA += 1.0 * num[i].a * num[i].g;
tB += 1.0 * num[i].b * num[i].g;
}
}
if ((double)A > tA) {
printf("-1 -1\n");
} else {
printf("%.9f %.9f\n", tA, tB);
for (int i = 0; i < n; i++) {
printf("%f", res[i]);
if (i == n - 1)
putchar('\n');
else
putchar(' ');
}
}
}
return 0;
}

# Epic Win!

#include <iostream>
#include <cstring>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;

#define PI acos(-1.0)
#define LL long long
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define mp make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "wb", stdout)
#define scan(x) scanf("%d", &x)
#define scan2(x, y) scanf("%d%d", &x, &y)
#define scan3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sqr(x) (x) * (x)
#define For(i,n) for(int i=1;i<=n;i++)

const int maxn = 50005;

struct Node {
int ch;
int to[3];
}fsm[maxn], res[maxn];
int n;

int main() {
srand(19951125);
while (scanf("%d", &n) != EOF) {
for (int i = 0; i < n; i++) {
char c = getchar();
while (c != 'P' && c != 'R' && c != 'S')
c = getchar();
if (c == 'R')
fsm[i].ch = 0;
if (c == 'P')
fsm[i].ch = 1;
if (c == 'S')
fsm[i].ch = 2;
for (int j = 0; j < 3; j++)
scanf("%d", &fsm[i].to[j]);
}
int c = 50000 / n;
for (int i = 0; i < n; i++)
for (int j = 0; j < c; j++) {
int cur = j * n + i, nxt = (j + 1) % c;
res[cur].ch = (fsm[i].ch + 1) % 3;
for (int k = 0; k < 3; k++)
res[cur].to[k] = nxt * n + rand() % n + 1;
res[cur].to[fsm[i].ch] = j * n + fsm[i].to[res[i].ch];
}
printf("%d\n", c * n);
for (int i = 0; i < c * n; i++) {
if (res[i].ch == 0)
putchar('R');
if (res[i].ch == 1)
putchar('P');
if (res[i].ch == 2)
putchar('S');
for (int j = 0; j < 3; j++)
printf(" %d", res[i].to[j]);
putchar('\n');
}
}
return 0;
}

# Filter

bitset暴力

#include <iostream>
#include <cstring>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <deque>
#include <bitset>
#include <algorithm>
#include<bitset>
using namespace std;

#define PI acos(-1.0)
#define LL long long
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define mp make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "wb", stdout)
#define scan(x) scanf("%d", &x)
#define scan2(x, y) scanf("%d%d", &x, &y)
#define scan3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sqr(x) (x) * (x)
#define vi vector<int>
#define pb push_back
#define For(i,n) for(int i=1;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define c(x) ( (isdigit(x)) ? (x-'0'):(x-'a'+10)  )
#define MAXN (1010)
char s[MAXN];
bitset<1010> a[MAXN];
bitset<1010> g[MAXN];
int m,n;
int lenp;
int lenu;
typedef unsigned long long ull;
ull p[MAXN],u[MAXN];
int main() {
//  freopen("F.in","r",stdin);
while(cin>>m) {
int len=m/4+(m%4>0);
For(i,n) a[i].reset();
cin>>lenp;
For(i,lenp) cin>>p[i];
scanf("%d",&n);
For(i,n) {
scanf("%s",s);
int tot=0;
for(int j=0;j<len;j++) {
int p=c(s[j]);
a[i][tot++]=p&1;
a[i][tot++]=(p>>1)&1;
a[i][tot++]=(p>>2)&1;
a[i][tot++]=(p>>3)&1;
}
}
//      For(i,n) {
//          Rep(j,m) cout<<a[i][j];puts("");
//      }
cin>>lenu;
For(i,lenu) {
g[i].reset();
cin>>u[i];
For(j,lenp) g[i][u[i]*p[j]%m] = 1;
}
vi ans;
For(i,n) {
For(j,lenu) if ( (g[j]^(a[i]&g[j])) . none() ) {
//              cout<<i<<' '<<j<<endl;
ans.pb(i); break;
}
}
int sz=ans.size();
printf("%d",sz);
Rep(i,sz) printf(" %d",ans[i]-1); puts("");
}
return 0;
}

# Improvements

2便LIS即可

#include <iostream>
#include <cstring>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;

#define PI acos(-1.0)
#define LL long long
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define mp make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "wb", stdout)
#define scan(x) scanf("%d", &x)
#define scan2(x, y) scanf("%d%d", &x, &y)
#define scan3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sqr(x) (x) * (x)
#define For(i,n) for(int i=1;i<=n;i++)

const int maxn = 200005;

int n;
int A[maxn];
int g[maxn], f1[maxn], f2[maxn];

int main() {
while (scanf("%d", &n) != EOF) {
for (int i = 0; i < n; i++) {
int t;
scanf("%d", &t);
A[t - 1] = i;
}
for (int i = 0; i < n; i++)
g[i] = 1000000000;
for (int i = 0; i < n; i++) {
int k = lower_bound(g, g + n, A[i]) - g;
f1[i] = k + 1;
g[k] = A[i];
}
reverse(A, A + n);
for (int i = 0; i < n; i++)
g[i] = 1000000000;
for (int i = 0; i < n; i++) {
int k = lower_bound(g, g + n, A[i]) - g;
f2[i] = k + 1;
g[k] = A[i];
}
int maxx = INT_MIN;
for (int i = 0; i < n; i++)
maxx = max(maxx, f1[i] + f2[n - i - 1] - 1);
printf("%d\n", maxx);
}
return 0;
}

# Jokewithpermutation

#include <iostream>
#include <cstring>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;

#define PI acos(-1.0)
#define LL long long
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define mp make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "wb", stdout)
#define scan(x) scanf("%d", &x)
#define scan2(x, y) scanf("%d%d", &x, &y)
#define scan3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sqr(x) (x) * (x)

int vis[205], L;
bool succ;
char S[205];

void DFS(int n)
{
if (n == 0) {
succ = true;
return ;
}
for (int i = 0; i < L; i++) {
if (n < 10) {
if (vis[i] > 0)
continue;
if (S[i] - '0' == n) {
vis[i] = n;
DFS(n - 1);
if (succ)
return ;
vis[i] = 0;
}
} else {
if (i == L - 1)
break;
if (vis[i] > 0 || vis[i + 1] > 0)
continue;
if (S[i] - '0' == n / 10 && S[i + 1] - '0' == n % 10) {
vis[i] = vis[i + 1] = n;
DFS(n - 1);
if (succ)
return ;
vis[i] = vis[i + 1] = 0;
}
}
}
}

int main() {
while (scanf("%s", S) != EOF) {
L = strlen(S);
if (L <= 9) {
for (int i = 0; i < L - 1; i++) {
putchar(S[i]);
putchar(' ');
}
putchar(S[L - 1]);
putchar('\n');
} else {
memset(vis, 0, sizeof(vis));
int n = (L - 9) / 2 + 9;
succ = false;
DFS(n);
putchar(S[0]);
for (int i = 1; i < L; i++) {
if (vis[i] != vis[i - 1])
putchar(' ');
putchar(S[i]);
}
putchar('\n');
}
}
return 0;
}

# Knockout Racing

#include <iostream>
#include <cstring>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;

#define PI acos(-1.0)
#define LL long long
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define mp make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "wb", stdout)
#define scan(x) scanf("%d", &x)
#define scan2(x, y) scanf("%d%d", &x, &y)
#define scan3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sqr(x) (x) * (x)
#define For(i,n) for(int i=1;i<=n;i++)

const int maxn = 1005;

int L[maxn], R[maxn];

int main() {
int n, m;
while (scanf("%d %d", &n, &m) != EOF) {
for (int i = 0; i < n; i++)
scanf("%d %d", &L[i], &R[i]);
while (m--) {
int l, r, t, res = 0;
scanf("%d %d %d", &l, &r, &t);
for (int i = 0; i < n; i++) {
int p = t % ((R[i] - L[i]) * 2);
if (p > R[i] - L[i])
p = R[i] - p + R[i] - L[i];
else
p = L[i] + p;
if (p >= l && p <= r)
res++;
}
printf("%d\n", res);
}
}
return 0;
}