重复局面

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
#include<bits/stdc++.h>

using namespace std;

map<string,int>m;

int main()
{
int n;
cin>>n;

string s[110];

for(int i=1;i<=n;i++)
{
for(int j=1;j<=8;j++)
{
string tep;
cin>>tep;
s[i]+=tep;
}
if(!(m.count(s[i])))
{
m[s[i]]=1;
cout<<1<<'\n';
}
else
{
m[s[i]]++;
cout<<m[s[i]]<<'\n';
}
}
return 0;
}

矩阵运算

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
#include<bits/stdc++.h>

using namespace std;

#define int long long

const int N = 1e4 + 10;
const int D = 25;

signed main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n, d;
int Q[N][D], K[N][D], V[N][D], w[N], tep[N][D] = { 0 }, end[N][D] = { 0 };
cin >> n >> d;

//cin juzhen
for (int i = 1; i <= n; i++)for (int j = 1; j <= d; j++)cin >> Q[i][j];
for (int i = 1; i <= n; i++)for (int j = 1; j <= d; j++)cin >> K[i][j];
for (int i = 1; i <= n; i++)for (int j = 1; j <= d; j++)cin >> V[i][j];

for (int i = 1; i <= n; i++)cin >> w[i];

//K^T*V
//memset(tep,1,sizeof(tep));
for (int i = 1; i <= d; i++)
for (int j = 1; j <= d; j++)
{
for (int m = 1; m <= n; m++)
tep[i][j] += K[m][i] * V[m][j];
}

//q*tep
for (int i = 1; i <= n; i++)
for (int j = 1; j <= d; j++)
{
for (int m = 1; m <= d; m++)
{
end[i][j] += Q[i][m] * tep[m][j];
}
}


for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= d; j++)
{
cout << end[i][j] * w[i] << " \n"[j == d];
}
}
return 0;
}

解压缩

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
76
77
78
79
80
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define N 2000007

int b[N], tot;

int Data[N * 10];

void add(int o, int l) {
if (o >= l) {
int p = tot - o + 1;
for (int i = 1; i <= l; ++i) Data[++tot] = Data[p++];
}
else {
int pp = tot - o + 1;
int p = pp;
for (int i = 1; i <= l; ++i) {
Data[++tot] = Data[p++];
if (i % o == 0) p = pp;
}
}
}

void pt(int x) {
if (x < 10) putchar(x + '0');
else putchar(x + 'a' - 10);
}

void print(int x) { pt(x >> 4); pt(x & 15); }

int main() {
int n; scanf("%d", &n);
bool f = 0;
for (int i = 1, x; i <= n; ++i) {
char c = getchar();
while (!isdigit(c) && !isalpha(c)) c = getchar();
x = isdigit(c) ? (c - '0') : (c - 'a' + 10);
c = getchar();
x = (x << 4) + (isdigit(c) ? (c - '0') : (c - 'a' + 10));
if (f) b[++tot] = x;
if ((x & (1 << 7)) == 0) f = true;
//print(x); puts("!");
}
n = tot; tot = 0;
//printf("%d\n", n);
for (int i = 1; i <= n; ++i) {
if ((b[i] & 3) == 0) { // data
int l = b[i] >> 2;
if (l >= 60) {
int tmpk = l - 59; l = 0;
for (int j = i + tmpk; j > i; --j) l = (l << 8) + b[j];
i += tmpk;
}
++l;
//printf("%d\n", l);
for (; l; --l) Data[++tot] = b[++i];
}
else if ((b[i] & 3) == 1) {
int l = ((b[i] >> 2) & 7) + 4;
int o = ((b[i] >> 5) << 8);
o += b[++i];
//printf("%d %d\n", l, o);
add(o, l);
}
else {
int l = (b[i] >> 2) + 1;
int o = (b[i + 2] << 8) + b[i + 1];
i += 2;
//printf("%d %d\n", l, o);
add(o, l);
}
}
for (int i = 1; i <= tot; ++i) {
print(Data[i]);
if (i % 8 == 0) puts("");
}
return 0;
}