GVKun编程网logo

The Swell by Ripple Conference in 2018

40

在这篇文章中,我们将为您详细介绍TheSwellbyRippleConferencein2018的内容。此外,我们还会涉及一些关于20+Rsynccommand’sswitchesandcommonu

在这篇文章中,我们将为您详细介绍The Swell by Ripple Conference in 2018的内容。此外,我们还会涉及一些关于20+ Rsync command’s switches and common usages with examples – Unix/Linux--reference、2018-2019 ICPC Southwestern European Regional Programming Contest (SWERC 2018)、2018浙江省赛(ACM) The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple、AP controller-centralized management-support-IPQ6010-IPQ5018-IPQ4019 motherboard的知识,以帮助您更全面地了解这个主题。

本文目录一览:

The Swell by Ripple Conference in 2018

The Swell by Ripple Conference in 2018

The 2nd Annual Swell by Ripple Conference is over! San Francisco Time On October 1st and 2nd, global experts in policy, payment and technology gathered at the Swell by Ripple conference in San Francisco to discuss future payment methods.

 

Ripple is the world''s first open payment network, through which any currency can be transferred. Compared with the traditional way of remittance by bank, there is no cross-border, cross-border payment of Ripple, the transaction can be confirmed within a few seconds, and the transaction cost is almost zero, easy and fast. And this meeting called Swell is Ripple''s annual conference. Then, what are the highlights of this Swell conference?

 

Ripple CEO: The three conditions of value Internet are indispensable

At the beginning of the conference, Brad Garlinghouse mentioned Ripple''s mission: to become the value of the Internet, so that the world can transmit and receive value just like today''s sending and receiving of information. But if you want to achieve the ultimate goal of "value transfer," the industry must first address the conditions that are currently missing: the transmission of goods, the transmission of data, and the transmission of funds. The three are indispensable.

 

When we conduct cross-border remittances now, complicated procedures, high costs, and trading hours of several days are all examples of the problem of capital transmission. And that''s exactly what Ripple is trying to solve with blockchain technology. For example, RippleNet, one of Ripple''s products, is a payment network that uses Ripple blockchain technology for cross-border transactions. RippleNet includes financial institutions in more than 40 countries. Recently, PNC Bank and the National Commercial Bank of the Kingdom of Saudi Arabia have joined the network.

 

xRapid officially launched

At the conference, Garlinghouse also announced a big ripple news: Ripple''s new product, xRapid, went live. That is to say, people can now use Ripple''s partner Cuallix to use Ripple''s token XRP to make real-time payments from the US to Mexico! This also means that Ripple has achieved phased results in solving the problem of fund transfer.

 

The significance of xRapid is that it is the actual settlement of the transaction. In addition, xRapid uses XRP, and other Ripple products do not have to use XRP, which is also of great significance to Ripple.

 

The xRapid developed by Ripple is very easy to use and user friendly, but the development process is very difficult and requires many very talented computer scientists. The global banking system is very complex, and xRapid wants to be a simple and efficient trading system in a complex banking system, and the challenges can be imagined. However, xRapid uses Ripple''s own token XRP as a “transfer station” for cross-border settlement. Recently, the XRP price has fluctuated and fluctuated greatly. Does this kind of volatility affect people''s confidence in using XRP as a “transfer station” for cross-border settlement?

 

Compared to the volatility of XRP a year ago, XRP is now much more stable. And if you use SWIFT for cross-border remittances now, since the entire transaction takes up to several days, the funds of the remitter are exposed to the risk of exchange rate fluctuations in these days, so they also bear certain risks. Of course, the fiat currency generally does not fluctuate as much as XRP, but it needs to be exposed to exchange rate risk for 3-5 days. If the sender uses xRapid and remittance through XRP, the transaction is completed more quickly. Exposure to the value fluctuations of the XRP or ripple exchange rate itself is only 3-5 seconds. As a result, exchange rate risk is significantly reduced as the time required for the remitter to expose the risk is significantly reduced.

 

Will Ripple enter the Chinese market in the future?

Regardless of whether it is remitted in or remitted out, China is one of the four countries with the most frequent cross-border remittances in the world. Therefore, Chinese banks and financial institutions want to interact with the rest of the world, and hope that this interaction can be accurate and rapid. Therefore, Ripple has a natural space for cooperation with China. Although Ripple does not currently have a Chinese customer, Cory revealed that Ripple has actions throughout Asia. As for when to enter China? It’s hard to imagine that in today’s global interactions, China’s remittance business will not want to use a faster, more convenient and cheaper way.

20+ Rsync command’s switches and common usages with examples – Unix/Linux--reference

20+ Rsync command’s switches and common usages with examples – Unix/Linux--reference

reference:http://crybit.com/rsync-commands-switches/

The “rsync” is a powerful command under the Linux environment. The rsync stands for Remote Sync. normally rsync is used to transfer file from one server(source) to another server(destination). rsync has a lot of switches or option for managing the command much usefully. Here I am explaining the switches of rsync command with examples. Rsync will actually look and see what in the file has changed and upload only the part of the file that has changed. Unlike ftp and other transfer solutions rsync doesn’t simply re-upload the entire file.

Common Syntax for Rsync:

# rsync [options] Source Destinations. 

Switches of rsync:

1,-v,–verboseIncrease verbosity.

Example:I’ve created a file ‘rsync’ under ‘/root/Rsync/’ for testing purpose.

root@server [~]# rsync -v /root/Rsync/rsync .
rsync

sent 65 bytes received 31 bytes 192.00 bytes/sec
total size is 0 speedup is 0.00

2,-r,–recursiveRecurse into directories.

3,-l,–linkscopy symlinks as symlinks.

4,-p,–permsPreserve permissions.

5,-t,–timesPreserve modification times.

6,-g,–groupPreserve group.

7,-o,–ownerpreserve owner (super-user only)

8,-DSame as –devices –specials.–devices : preserve device files (super-user only).–specials : preserve special files.

9,-H,–hard-linksPreserve hard links

10,-A,–aclsPreserve ACLs (implies –perms)

11,-X,–xattrsPreserve extended attributes

12,-a,–archiveThis is very important rsync switch,because it can be done the functions of some other switches combinations.Archive mode; equals -rlptgoD (no -H,-X)

13,-q,–quietSuppress non-error messages.

14,To specify the file size for sync:–max-size=SIZEDon’t transfer any file larger than SIZE–min-size=SIZEDon’t transfer any file smaller than SIZE

15,–deleteDelete extraneous files from destination dirs.

16,W,–whole-filecopy files whole (without delta-xfer algorithm)

17,-u,–updateSkip files that are newer on the receiver. Means,Do Not Overwrite the Modified Files at the Destination.

18,–progressView the rsync Progress during Transfer.

19,Include and Exclude Pattern.–include–excludePatterns are expressed in single quote.

Examples:

[root@ser crybit]# rsync -avz --include 'c*' --exclude '*' /root/crybit/ 109.200.11.67:/root/Rsinc101
root@109.200.11.67's password:
stdin: is not a tty
sending incremental file list
cry1.doc
cry2.doc
cry3.doc
cry4.doc
cry5.doc

sent 267 bytes received 107 bytes 68.00 bytes/sec
total size is 0 speedup is 0.00

In the above example files starting with ‘c’ are included for Rsync and all other files are excluded on Rsync operation.

20 -e : Rsync over Shell(SSH)Syntax:

# rsync -avz -e ssh Source Destination 

Some useful switches combinations and Useful “Rsync” examples:

1,How to Sync two directories in the same machine ?I have created two directories(also some files inside each dir) under /root location to check the rsync usages.

/root/Rsync1/
/root/Rsync2/

Example:

root@server [~]# rsync -zvr /root/Rsync1/ /root/Rsync2/
sending incremental file list
rsync1.txt
rsync10.txt
rsync2.txt
rsync3.txt
......
......
sent 502 bytes  received 202 bytes  1408.00 bytes/sec
total size is 0  speedup is 0.00

Where,-z is to enable compression-v verbose-r indicates recursive

2,Preserve the following option while Sync files using -a switch.

r,l,p,t,g,o,D : Switch details are mentioned in the above section.
Recursive mode,symbolic links,permissions,timestamp,owner and group 

See the example below:

root@server [~]# ll /root/Rsync1/rsync10.txt
-rw-r--r-- 1 root root 0 Feb 17 07:40 /root/Rsync1/rsync10.txt
root@server [~]#  ll /root/Rsync2/rsync10.txt
-rw-r--r-- 1 root root 0 Feb 17 07:40 /root/Rsync2/rsync10.txt

3,How to Rsync files from Remote Server to local ?It is quit similar to SCP,the Syntax for doing the same is pasted below:

# rsync -azv Remote-IP:/path/for/Sync /Path/to/Sync

Some examples:Sync the directory from remote to local

[root@ser crybit]# rsync -azv MY.SERVER.IP:/root/Rsync1 /root/crybit/
root@109.200.11.67's password:
stdin: is not a tty
receiving incremental file list
Rsync1/
Rsync1/rsync1.txt
Rsync1/rsync10.txt
Rsync1/rsync2.txt
Rsync1/rsync3.txt
.....
.....
sent 205 bytes  received 527 bytes  77.05 bytes/sec
total size is 0  speedup is 0.00

Sync all files from remote to local

[root@ser crybit]# rsync -azv 109.200.11.67:/root/Rsync1/* /root/crybit/
root@109.200.11.67's password:
stdin: is not a tty
receiving incremental file list
rsync1.txt
rsync10.txt
rsync2.txt
rsync3.txt
...
...
sent 201 bytes  received 499 bytes  93.33 bytes/sec
total size is 0  speedup is 0.00

4,How to sync files from local to Remote Server ?Syntax:

# rsync -azv /local-path/for/Sync/  Remote-IP:/path/to/Sync

Examples:

[root@support crybit]# rsync -avz /root/crybit/ 109.200.11.67:/root/Rsinc101
root@109.200.11.67's password:
stdin: is not a tty
sending incremental file list
created directory /root/Rsinc101
./
rsync1.txt
rsync10.txt
rsync2.txt
rsync3.txt
...
...
sent 1028 bytes  received 399 bytes  190.27 bytes/sec
total size is 0  speedup is 0.00
Note 1 : In example 3 and 4 you can use user@IP:/path format,if you have only the user privilege on server
Note 2 : The rsync will automatically create the destination directory/location if it isn't there.

That’s it !! 

Related:, , , , , , , , , , , , ,, , , ,

2018-2019 ICPC Southwestern European Regional Programming Contest (SWERC 2018)

2018-2019 ICPC Southwestern European Regional Programming Contest (SWERC 2018)

7 题,一般般。F 没搞出来很可惜。

自己这场题还是充当翻译机的角色…… 中间发现 D 和 H 很可写,马上就把队友赶下来了 (


A:

solver:lzh

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef pair<int, int> pii;
 4 typedef long long ll;
 5 #define ff first
 6 #define ss second
 7 
 8 int a[1000010];
 9 int main() {
10     int n, k; scanf("%d%d", &n, &k);
11     for (int i = 1; i <= n; i++)a[i] = 1;
12     int ans = 0, cur = 0;
13     while (k--) {
14         int m, cnt = cur; scanf("%d", &m);
15         for (int i = 1; i * m <= n; i++) {
16             if (!a[i * m])cnt--;
17             else cnt++;
18             a[i * m] ^= 1;
19         }
20         ans = max(ans, cnt);
21         //cout<<cnt<<endl;
22         cur = cnt;
23     }
24     printf("%d\n", ans);
25 }
View Code

B:

solver:lzh

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef pair<int, int> pii;
 4 typedef long long ll;
 5 #define ff first
 6 #define ss second
 7 
 8 int dl[20][100010], dr[20][100010];
 9 int query(int d[][100010], int l, int r, int maxx) {
10     int t = log2(r - l + 1);
11     if (maxx)return max(d[t][l], d[t][r - (1 << t) + 1]);
12     return min(d[t][l], d[t][r - (1 << t) + 1]);
13 }
14 void init(int d[][100010], int a[], int len, int maxx) {
15     for (int i = 0; i < len; i++)d[0][i] = a[i];
16     int t = 1;
17     for (int i = 1; t <= len; i++) {
18         for (int j = 0; j + t < len; j++)
19             if (maxx)d[i][j] = max(d[i - 1][j], d[i - 1][j + t]);
20             else d[i][j] = min(d[i - 1][j], d[i - 1][j + t]);
21         t <<= 1;
22     }
23 }
24 
25 int L[100010], R[100010];
26 int main() {
27     int n; scanf("%d", &n);
28     for (int i = 0; i < n; i++)scanf("%d%d", &L[i], &R[i]);
29     init(dl, L, n, 1);
30     init(dr, R, n, 0);
31 
32     int ans = 1;
33     for (int i = 1; i <= n; i++) {
34         int l = ans, r = n - i + 1;
35         while (l <= r) {
36             int mid = l + r >> 1;
37             //cout<<i<<" "<<mid<<" "<<query(dl,i-1,i+mid-2,1)<<" "<<query(dr,i-1,i+mid-2,0)<<"\n";
38             if (query(dr, i - 1, i + mid - 2, 0) - query(dl, i - 1, i + mid - 2, 1) + 1 >= mid) {
39                 ans = max(ans, mid); l = mid + 1;
40             } else r = mid - 1;
41         }
42     }
43     printf("%d\n", ans);
44 }
View Code

C:

完全没看的防 AK

D:

solver:czq

 1 /* basic header */
 2 #include <bits/stdc++.h>
 3 /* define */
 4 #define ll long long
 5 #define dou double
 6 #define pb emplace_back
 7 #define mp make_pair
 8 #define sot(a,b) sort(a+1,a+1+b)
 9 #define rep1(i,a,b) for(int i=a;i<=b;++i)
10 #define rep0(i,a,b) for(int i=a;i<b;++i)
11 #define eps 1e-8
12 #define int_inf 0x3f3f3f3f
13 #define ll_inf 0x7f7f7f7f7f7f7f7f
14 #define lson (curpos<<1)
15 #define rson (curpos<<1|1)
16 /* namespace */
17 using namespace std;
18 /* header end */
19 
20 const int maxn = 200010, lim = 100001;
21 struct Point {
22     int x, y;
23 } p[maxn];
24 int n, x, y, maxx[maxn], minn[maxn], monument[maxn];
25 
26 void init() {
27     for (int i = 0; i < maxn; i++) {
28         p[i].x = p[i].y = monument[i] = 0;
29         maxx[i] = -1;
30     }
31     memset(minn, 0x3f, sizeof(minn));
32 }
33 
34 int main() {
35     while (~scanf("%d%d", &x, &y)) {
36         init();
37         scanf("%d", &n);
38         for (int i = 0; i < n; i++) {
39             scanf("%d%d", &p[i].x, &p[i].y);
40             maxx[p[i].x] = max(maxx[p[i].x], p[i].y);
41             minn[p[i].x] = min(minn[p[i].x], p[i].y);
42         }
43         int cnt = 0;
44         for (int i = 0; i < lim; i++) {
45             if (maxx[i] != -1 && minn[i] != 0x3f3f3f3f) {
46                 monument[cnt++] = maxx[i];
47                 monument[cnt++] = minn[i];
48             }
49         }
50         sort(monument, monument + cnt);
51         ll ans = x - 1, mid = monument[(cnt - 1) / 2];
52         for (int i = 0; i < lim; i++)
53             if (maxx[i] != -1 && minn[i] != 0x3f3f3f3f)
54                 ans += (ll)maxx[i] - minn[i] + abs(mid - maxx[i]) + abs(mid - minn[i]);
55         printf("%lld\n", ans);
56     }
57     return 0;
58 }
View Code

E:

solver:zyh、lzh

 1 #include <iostream>
 2 #include <string>
 3 using namespace std;
 4 char str[50001];
 5 string names[50001];
 6 int d[50001];
 7 int validate(int x) {
 8     if (x > 49) return 49;
 9     if (x < -50) return -50;
10     return x;
11 }
12 int main() {
13     int n;
14     int sum = 0;
15     scanf("%d", &n);
16     for (int i = 0; i < n; ++i) {
17         scanf("%s%d", str, &d[i]);
18         d[i] *= 100;
19         sum += d[i];
20         names[i] = str;
21     }
22     int l = 10000 - sum - 49 * (n - 1);
23     int r = 10000 - sum + 50 * (n - 1);
24     if (r > 49) r = 49;
25     if (l < -50) l = -50;
26     if (l <= r) {
27         for (int i = 0; i < n; ++i) {
28             printf("%s %.2f %.2f\n", names[i].c_str(), max(0, d[i] + l) / 100.0, min(10000, d[i] + r) / 100.0);
29         }
30     } else printf("IMPOSSIBLE\n");
31 }
View Code

F:

没搞出来

G:

很恶心的字符串题

H:

solver:czq

  1 /* basic header */
  2 #include <bits/stdc++.h>
  3 /* define */
  4 #define ll long long
  5 #define dou double
  6 #define pb emplace_back
  7 #define mp make_pair
  8 #define sot(a,b) sort(a+1,a+1+b)
  9 #define eps 1e-8
 10 #define int_inf 0x3f3f3f3f
 11 #define ll_inf 0x7f7f7f7f7f7f7f7f
 12 #define lson (curpos<<1)
 13 #define rson (curpos<<1|1)
 14 /* namespace */
 15 using namespace std;
 16 /* header end */
 17 using namespace std;
 18 
 19 const int maxn = 1e5 + 10;
 20 struct Node {
 21     int x, y, z, id, cnt;
 22     bool operator<(const Node &rhs)const {
 23         return x != rhs.x ? x < rhs.x : y != rhs.y ? y < rhs.y : z < rhs.z;
 24     }
 25 } info[maxn], temp[maxn];
 26 int n, m, num = 0, sum = 0, a[maxn], dis1[maxn], dis2[maxn], dis3[maxn], vis[maxn], head[maxn];
 27 vector<pair<int, int>>g[maxn];
 28 priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>q;
 29 
 30 int lowbit(int x) {
 31     return x & -x;
 32 }
 33 
 34 void add(int pos, int val) {
 35     while (pos < maxn) a[pos] += val, pos += lowbit(pos);
 36 }
 37 
 38 int query(int pos) {
 39     int ret = 0;
 40     while (pos) ret += a[pos], pos -= lowbit(pos);
 41     return ret;
 42 }
 43 
 44 void dijkstra(int *dis, int st) {
 45     for (int i = 0; i <= n; ++i) dis[i] = int_inf;
 46     dis[st] = 0;
 47     while (q.size()) q.pop();
 48     q.push(mp(dis[st], st));
 49     while (q.size()) {
 50         pair<int, int> temp = q.top(); q.pop();
 51         if (temp.first > dis[temp.second]) continue;
 52         for (int i = 0; i < (int)g[temp.second].size(); ++i) {
 53             if (dis[temp.second] + g[temp.second][i].first < dis[g[temp.second][i].second]) {
 54                 dis[g[temp.second][i].second] = dis[temp.second] + g[temp.second][i].first;
 55                 q.push(mp(dis[g[temp.second][i].second], g[temp.second][i].second));
 56             }
 57         }
 58     }
 59 }
 60 
 61 void init() {
 62     for (int i = 0; i < maxn; i++) vis[i] = 0;
 63 }
 64 
 65 void cdq(int l, int r) {
 66     if (r - l <= 1) return;
 67     int mid = (r + l) >> 1;
 68     cdq(l, mid); cdq(mid, r);
 69     int lPtr = l, rPtr = mid, cnt = 0;
 70     while (lPtr < mid && rPtr < r) {
 71         if (info[lPtr].y <= info[rPtr].y) {
 72             add(info[lPtr].z, 1);
 73             temp[cnt++] = info[lPtr++];
 74         } else {
 75             int curr = query(info[rPtr].z);
 76             if (curr) vis[info[rPtr].id] = info[rPtr].cnt;
 77             temp[cnt++] = info[rPtr++];
 78         }
 79     }
 80     while (rPtr < r) {
 81         int curr = query(info[rPtr].z);
 82         if (curr) vis[info[rPtr].id] = info[rPtr].cnt;
 83         temp[cnt++] = info[rPtr++];
 84     }
 85     for (int i = l; i < lPtr; ++i) add(info[i].z, -1);
 86     while (lPtr < mid) temp[cnt++] = info[lPtr++];
 87     for (int i = 0; i < cnt; ++i) info[i + l] = temp[i];
 88 }
 89 
 90 int main() {
 91     scanf("%d%d", &n, &m); sum = n, num = 0;
 92     while (m--) {
 93         int u, v, w;
 94         scanf("%d%d%d", &u, &v, &w);
 95         g[u].pb(mp(w, v)); g[v].pb(mp(w, u));
 96     }
 97     // maintain distance
 98     dijkstra(dis1, 0); dijkstra(dis2, 1); dijkstra(dis3, 2);
 99     for (int i = 0; i < n; ++i)  info[i].x = dis1[i], info[i].y = dis2[i], info[i].z = dis3[i], head[++num] = info[i].z;
100     sort(head + 1, head + 1 + num);
101     // li san hua
102     num = unique(head + 1, head + 1 + num) - head - 1;
103     for (int i = 0; i < n; ++i) info[i].z = lower_bound(head + 1, head + 1 + num, info[i].z) - head;
104     sort(info, info + n);
105     int p = 1, tot = 0;
106     // spj equal
107     for (int i = 0; i < n; ++i) {
108         if (info[i].x == info[i + 1].x && info[i].y == info[i + 1].y && info[i].z == info[i + 1].z) {
109             p++; continue;
110         }
111         info[i].cnt = p; info[tot++] = info[i]; p = 1;
112     }
113     n = tot;
114     for (int i = 0; i < n; ++i) info[i].id = i;
115     cdq(0, n);
116     for (int i = 0; i < n; ++i) sum -= vis[i];
117     printf("%d\n", sum);
118 }
View Code

I:

solver:lzh

  1 #include<bits/stdc++.h>
  2 using namespace std;
  3 typedef pair<int, int> pii;
  4 typedef long long ll;
  5 #define ff first
  6 #define ss second
  7 
  8 char s[1010][1010];
  9 int vis[1010][1010], dd[8][2] = {-1, 0, -1, -1, -1, 1, 0, 1, 0, -1, 1, 0, 1, -1, 1, 1};
 10 
 11 int abc[3][15] = {{1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1},
 12     {1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1},
 13     {1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1}
 14 };
 15 int add1[20], add2[20];
 16 
 17 int check(int x, int y, int n, int m, char cur) {
 18     for (int i = x; i < x + n; i++)
 19         for (int j = y; j < y + m; j++)
 20             if (s[i][j] != cur || vis[i][j])return 1;
 21     return 0;
 22 }
 23 
 24 int find(int stx, int sty, int x, int y, int cur) {
 25     add1[0] = 0, add1[1] = x, add1[2] = x + y;
 26     for (int i = 3; i < 15; i++)add1[i] = add1[i % 3];
 27     add2[0] = 0, add2[3] = x, add2[6] = x + y, add2[9] = 2 * x + y, add2[12] = 2 * x + 2 * y;
 28     for (int i = 0; i < 5; i++)
 29         for (int j = 1; j < 3; j++)add2[3 * i + j] = add2[3 * i + j - 1];
 30     //for(int i=0;i<15;i++)printf("%d ",add2[i]);printf("\n");
 31 
 32     for (int i = 0; i < 15; i++) {
 33         int addn = 0, addm = 0;
 34         if (i / 3 % 2 == 0)addn = x; else addn = y;
 35         if (i % 3 % 2 == 0)addm = x; else addm = y;
 36 
 37         char findchar = ''.'';
 38         if (abc[cur][i])findchar = ''#'';
 39         if (check(stx + add2[i], sty + add1[i], addn, addm, findchar)) {
 40             //printf("%d\n",i);
 41             //printf("%d %d %d %d\n",stx+add2[i],sty+add1[i],addn,addm);
 42             return 0;
 43         }
 44     }
 45     return 1;
 46 }
 47 
 48 int main() {
 49     int ansa = 0, ansb = 0, ansc = 0;
 50     int n, m; scanf("%d%d", &m, &n);
 51     for (int i = 1; i <= n; i++)scanf("%s", s[i] + 1);
 52     for (int i = 2; i <= n - 1; i++)
 53         for (int j = 2; j <= m - 1; j++)
 54             if (s[i][j] == ''#'') {
 55                 int gg = 0;
 56                 for (int k = 0; k < 8; k++)
 57                     if (s[i + dd[k][0]][j + dd[k][1]] == ''#'') {
 58                         gg++;
 59                         break;
 60                     }
 61                 if (!gg)s[i][j] = ''.'';
 62             }
 63 
 64     for (int i = 2; i <= n - 1; i++)
 65         for (int j = 2; j <= m - 2; j++)
 66             if (s[i][j] == ''.'' && s[i][j + 1] == ''#'' && !vis[i][j]) {
 67                 int a = 1, b = 1;
 68                 for (int k = j + 2; k <= m - 2; k++)
 69                     if (s[i][k] == ''#'')a++;
 70                     else break;
 71                 for (int k = i + 1; k <= n - 2; k++)
 72                     if (s[k][j + 1] == ''#'')b++;
 73                     else break;
 74 
 75                 int x = 2 * a - b, y = 2 * b - 3 * a;
 76                 if (x <= 0 || y <= 0)continue;
 77 
 78                 int gg = 0;
 79                 for (int k = j; k <= j + a + 1; k++)
 80                     if (s[i - 1][k] == ''#'' || s[i + b][k] == ''#'') {
 81                         gg++;
 82                         break;
 83                     }
 84                 if (gg)continue;
 85                 for (int k = i; k <= i + b - 1; k++)
 86                     if (s[k][j] == ''#'' || s[k][j + a + 1] == ''#'') {
 87                         gg++;
 88                         break;
 89                     }
 90                 if (gg)continue;
 91 
 92                 int cur = 0;
 93                 if (s[i][j + x + 1] == ''#'' && s[i + x + y][j + x + 1] == ''#'' && s[i + 2 * (x + y)][j + x + 1] == ''.'')cur = 1;
 94                 if (s[i][j + x + 1] == ''#'' && s[i + x + y][j + x + 1] == ''#'' && s[i + 2 * (x + y)][j + x + 1] == ''#'')cur = 2;
 95                 if (s[i][j + x + 1] == ''#'' && s[i + x + y][j + x + 1] == ''.'' && s[i + 2 * (x + y)][j + x + 1] == ''#'')cur = 3;
 96 
 97                 if (!cur)continue;
 98 
 99                 //printf("%d %d %d\n",i,j,cur);
100 
101                 if (find(i, j + 1, x, y, cur - 1)) {
102                     for (int visx = i - 1; visx <= i + b; visx++)
103                         for (int visy = j; visy <= j + a + 1; visy++)
104                             vis[visx][visy]++;
105                     if (cur == 1)ansa++;
106                     else if (cur == 2)ansb++;
107                     else ansc++;
108                 }
109 
110             }
111     /*for(int i=1;i<=n;i++,printf("\n"))
112         for(int j=1;j<=m;j++)printf("%d",vis[i][j]);*/
113     printf("%d %d %d\n", ansa, ansb, ansc);
114 }
View Code

J:

看都看不懂的奇怪数学题,像是乱搞

K:

solver:zyh

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 char str[1001];
 4 int dp[1001][1001];
 5 long long strhash[1001];
 6 long long M = 1000000007;
 7 long long p[1001];
 8 long long getHash(int l, int r) {
 9     l++; r++;
10     return (strhash[r] - (strhash[l - 1] * p[r - l + 1]) % M + M) % M;
11 }
12 int getKey(char ch) {
13     if (ch >= ''a'' && ch <= ''z'') return ch - ''a'' + 1;
14     if (ch >= ''A'' && ch <= ''Z'') return ch - ''A'' + 27;
15     return ch - ''0'' + 54;
16 }
17 int solve(int l, int r) {
18     if (~dp[l][r]) return dp[l][r];
19     if (l == r) {
20         dp[l][r] == 1;
21         return 1;
22     }
23     int ans = 99999999;
24     for (int i = 1; i <= r - l; ++i) {
25         int j;
26         long long rep = getHash(l, l + i - 1);
27         for (j = l; j <= r - i + 1; j += i) if (rep != getHash(j, j + i - 1)) break;
28         int f1, f2;
29         f1 = f2 = 0;
30         f1 = solve(l, l + i - 1);
31         if (j <= r) f2 = solve(j, r);
32         ans = min(ans, f1 + f2);
33     }
34     dp[l][r] = ans;
35     return ans;
36 }
37 int main() {
38     int len;
39     scanf("%d", &len);
40     scanf("%s", str);
41     p[0] = 1;
42     for (int i = 1; i <= len; ++i) p[i] = p[i - 1] * 71 % M;
43     strhash[0] = 0;
44     for (int i = 1; i <= len; ++i) strhash[i] = ((strhash[i - 1] * 71) % M + getKey(str[i - 1])) % M;
45     //cout<<getHash(0,10)<<'' ''<<getHash(11,21)<<endl;
46     memset(dp, -1, sizeof(dp));
47     printf("%d\n", solve(0, len - 1));
48 }
View Code

2018浙江省赛(ACM) The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple

我是铁牌选手

这次比赛非常得爆炸,可以说体验极差,是这辈子自己最脑残的事情之一。

天时,地利,人和一样没有,而且自己早早地就想好了甩锅的套路。

按理说不开K就不会这么惨了啊,而且自己也是毒,不知道段错误也可以是MLE,而且我的内存就是卡了那么一点点,在比赛紧张的状态下人也变傻了吧。

这次的题目难度是两边到中间一次递增的,但是我也不懂榜怎么会那样

 A
Peak
Time Limit: 1 Second       Memory Limit: 65536 KB

A sequence of  integers  is called a peak, if and only if there exists exactly one integer  such that , and  for all , and  for all .

Given an integer sequence, please tell us if it''s a peak or not.

Input

There are multiple test cases. The first line of the input contains an integer , indicating the number of test cases. For each test case:

The first line contains an integer  (), indicating the length of the sequence.

The second line contains  integers  (), indicating the integer sequence.

It''s guaranteed that the sum of  in all test cases won''t exceed .

Output

For each test case output one line. If the given integer sequence is a peak, output "Yes" (without quotes), otherwise output "No" (without quotes).

Sample Input

7
5
1 5 7 3 2
5
1 2 1 2 1
4
1 2 3 4
4
4 3 2 1
3
1 2 1
3
2 1 2
5
1 2 3 1 2

Sample Output

Yes
No
No
No
Yes
No
No

 A就是判断前一段递增,后一段递减。所以你找到最大值就好了

#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N];
int la()
{
    int pos=0;
    for(int i=1;i<n;i++)
        if(a[pos]<a[i])pos=i;
    if(pos==0||pos==n-1)return 0;
    for(int i=1;i<=pos;i++)
        if(a[i-1]>=a[i])return 0;
    for(int i=pos+1;i<n;i++)
        if(a[i-1]<=a[i])return 0;
    return 1;
}
int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        cin>>n;
        for(int i=0;i<n;i++)cin>>a[i];
        cout<<(la()?"Yes":"No")<<"\n";
    }
    return 0;
}
B
King of Karaoke
Time Limit: 1 Second       Memory Limit: 65536 KB

It''s Karaoke time! DreamGrid is performing the song Powder Snow in the game King of Karaoke. The song performed by DreamGrid can be considered as an integer sequence , and the standard version of the song can be considered as another integer sequence . The score is the number of integers  satisfying  and .

As a good tuner, DreamGrid can choose an integer  (can be positive, 0, or negative) as his tune and add  to every element in . Can you help him maximize his score by choosing a proper tune?

Input

There are multiple test cases. The first line of the input contains an integer  (about 100), indicating the number of test cases. For each test case:

The first line contains one integer  (), indicating the length of the sequences  and .

The second line contains  integers  (), indicating the song performed by DreamGrid.

The third line contains  integers  (), indicating the standard version of the song.

It''s guaranteed that at most 5 test cases have .

Output

For each test case output one line containing one integer, indicating the maximum possible score.

Sample Input

2
4
1 2 3 4
2 3 4 6
5
-5 -4 -3 -2 -1
5 4 3 2 1

Sample Output

3
1

Hint

For the first sample test case, DreamGrid can choose  and changes  to .

For the second sample test case, no matter which  DreamGrid chooses, he can only get at most 1 match.

 和上次的题目一样,直接做差就好了

#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
unordered_map<int,int>M;
int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        M.clear();
        int n,ma=0;
        cin>>n;
        for(int i=0;i<n;i++)cin>>a[i];
        for(int i=0,x;i<n;i++)
            cin>>x,M[a[i]-x]++;
        for(auto X:M)ma=max(ma,X.second);
        cout<<ma<<"\n";
    }
    return 0;
}
 F
Now Loading!!!
Time Limit: 1 Second       Memory Limit: 131072 KB

DreamGrid has  integers . DreamGrid also has  queries, and each time he would like to know the value of

 
for a given number  , where .

 

Input

There are multiple test cases. The first line of input is an integer  indicating the number of test cases. For each test case:

The first line contains two integers  and  () -- the number of integers and the number of queries.

The second line contains  integers  ().

The third line contains  integers  ().

It is guaranteed that neither the sum of all  nor the sum of all  exceeds .

Output

For each test case, output an integer , where  is the answer for the -th query.

Sample Input

2
3 2
100 1000 10000
100 10
4 5
2323 223 12312 3
1232 324 2 3 5

Sample Output

11366
45619

 有一个向下取整还有向上取整,所以去枚举分母做前缀和优化,卡MLE是真的骚

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e5+5,MD=1e9;
ll sum[32][N];
int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        int n,m;
        cin>>n>>m;
        for(int i=1;i<=n;i++)
            cin>>sum[0][i];
        sort(sum[0]+1,sum[0]+n+1);
        for(int i=1;i<32;i++)
            for(int j=1;j<=n;j++)
            sum[i][j]=sum[0][j]/i+sum[i][j-1];
        ll ans=0;
        for(int i=0,p;i<m;i++)
        {
            cin>>p;
            ll ans1=1,ans2=0;
            for(int j=1;;j++)
            {
                int pos1=lower_bound(sum[0]+1,sum[0]+1+n,ans1+1)-sum[0],pos2=upper_bound(sum[0]+1,sum[0]+1+n,ans1*p)-sum[0]-1;
                if(pos1==n+1)break;
                if(pos1<=pos2)ans2=(ans2+sum[j][pos2]-sum[j][pos1-1])%MD;
                ans1=ans1*p;
            }
            ans=(ans+ans2*(i+1))%MD;
        }
        cout<<ans<<"\n";
    }
    return 0;
}
 I
Magic Points
Time Limit: 1 Second       Memory Limit: 65536 KB       Special Judge

Given an integer , we say a point  on a 2D plane is a magic point, if and only if both  and  are integers, and exactly one of the following conditions is satisfied:

  •  and ;

  •  and ;

  •  and ;

  •  and .

It''s easy to discover that there are  magic points in total. These magic points are numbered from  to  in counter-clockwise order starting from .

DreamGrid can create  magic lines from these magic points. Each magic line passes through exactly two magic points but cannot be parallel to the line  or  (that is to say, the coordinate axes).

The intersections of the magic lines are called dream points, and for some reason, DreamGrid would like to make as many dream points as possible. Can you tell him how to create these magic lines?

Input

There are multiple test cases. The first line of input contains an integer  (about 100), indicating the number of test cases. For each test case, there is only one integer  ().

Output

For each case output  integers  in one line separated by one space, indicating that in your answer, point  and point  is connected by a line for all .

If there are multiple answers, you can print any of them.

Sample Input

3
2
3
4

Sample Output

0 2 1 3
1 4 2 5 3 6
0 6 1 9 3 8 4 10

Hint

The sample test cases are shown as follow:

4n-4个点让你构造直线而且相交点最多,先考虑让他们同方向的,也就是斜率相同的,但是不一定可以构造出来
但是首先要明确的就是按照边走,i连上n+i
最后一条线刚开始直接把对角线的点相连。但是这样有可能会交于同一点,所以是要找最后一点相连还有他的斜率
n==5也是特殊的,太菜了,哎。不过比赛时这个题目还是可以开的
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int ans[N];
int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        if(n==2)cout<<"0 2 1 3\n";
        else if(n==3)cout<<"1 4 2 5 3 6\n";
        else if(n==4)cout<<"0 6 1 9 3 8 4 10\n";
        else if(n==5)cout<<"0 5 1 6 2 7 3 8 11 13\n";
        else
        {
            for(int i=0;i<n-1;i++)cout<<i<<" "<<n+i<<" ";
            cout<<n*4-5<<" "<<n+n<<"\n";
        }
    }
    return 0;
}
J
CONTINUE...?
Time Limit: 1 Second       Memory Limit: 65536 KB       Special Judge

DreamGrid has  classmates numbered from  to . Some of them are boys and the others are girls. Each classmate has some gems, and more specifically, the -th classmate has  gems.

DreamGrid would like to divide the classmates into four groups  and  such that:

  • Each classmate belongs to exactly one group.

  • Both  and  consist only of girls. Both  and  consist only of boys.

  • The total number of gems in  and  is equal to the total number of gems in  and .

Your task is to help DreamGrid group his classmates so that the above conditions are satisfied. Note that you are allowed to leave some groups empty.

Input

There are multiple test cases. The first line of input is an integer  indicating the number of test cases. For each test case:

The first line contains an integer  () -- the number of classmates.

The second line contains a string  () consisting of 0 and 1. Let  be the -th character in the string . If , the -th classmate is a boy; If , the -th classmate is a girl.

It is guaranteed that the sum of all  does not exceed .

Output

For each test case, output a string consists only of {1, 2, 3, 4}. The -th character in the string denotes the group which the -th classmate belongs to. If there are multiple valid answers, you can print any of them; If there is no valid answer, output "-1" (without quotes) instead.

Sample Input

5
1
1
2
10
3
101
4
0000
7
1101001

Sample Output

-1
-1
314
1221
3413214

这个就是凑数的题目,可以凑出来的,贪心选择或者找其中的一段区间都是可以的

#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int ans[N];
int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        string s;
        cin>>s;
        long long sum=n*1LL*(n+1)/2;
        if(sum%2)cout<<"-1\n";
        else
        {
            sum/=2;
            for(int i=n-1;i>=0;i--)
            {
                if(sum>i)
                    sum-=(i+1),ans[i]=(s[i]==''1'')?3:1;
                else ans[i]=(s[i]==''1'')?4:2;
            }
            for(int i=0;i<n;i++)cout<<ans[i];
            cout<<"\n";
        }
    }
    return 0;
}
L
Doki Doki Literature Club
Time Limit: 1 Second       Memory Limit: 65536 KB

Doki Doki Literature Club! is a visual novel developed by Team Salvato. The protagonist is invited by his childhood friend, Sayori, to join their high school''s literature club. The protagonist then meets the other members of the club: Natsuki, Yuri, and the club president Monika. The protagonist starts to participate in the club''s activities such as writing and sharing poetry, and grows close to the four girls. What a lovely story!

A very important feature of the game is its poetry writing mechanism. The player is given a list of various words to select from that will make up his poem. Each girl in the Literature Club has different word preferences, and will be very happy if the player''s poem is full of her favorite words.

The poem writing mini-game (from wikipedia)

BaoBao is a big fan of the game and likes Sayori the most, so he decides to write a poem to please Sayori. A poem of  words  is nothing more than a sequence of  strings, and the happiness of Sayori after reading the poem is calculated by the formula

 
where   is the happiness and  is Sayori''s preference to the word .

 

Given a list of  words and Sayori''s preference to each word, please help BaoBao select  words from the list and finish the poem with these  words to maximize the happiness of Sayori.

Please note that each word can be used at most once!

Input

There are multiple test cases. The first line of input contains an integer  (about 100), indicating the number of test cases. For each test case:

The first line contains two integers  and  (), indicating the number of words and the length of the poem.

For the following  lines, the -th line contains a string consisting of lowercased English letters  () and an integer  (), indicating the -th word and Sayori''s preference to this word. It''s guaranteed that  for all .

Output

For each test case output one line containing an integer  and  strings  separated by one space, indicating the maximum possible happiness and the corresponding poem. If there are multiple poems which can achieve the maximum happiness, print the lexicographically smallest one.

Please, DO NOT output extra spaces at the end of each line, or your answer may be considered incorrect!

sequence of  strings  is lexicographically smaller than another sequence of  strings , if there exists a  () such that  for all  and  is lexicographically smaller than .

string  is lexicographically smaller than another string , if there exists a  () such that  for all  and , or  for all  and .

Sample Input

4
10 8
hello 0
world 0
behind 0
far 1
be 2
spring 10
can 15
comes 20
winter 25
if 200
5 5
collegiate 0
programming -5
zhejiang 10
provincial 5
contest -45
3 2
bcda 1
bcd 1
bbbbb 1
3 2
a 1
aa 1
aaa 1

Sample Output

2018 if winter comes can spring be far behind
15 zhejiang provincial collegiate programming contest
3 bbbbb bcd
3 a aa

 仅仅是个sort,读懂题意就可以做了

#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
struct T
{
    string s;
    int va;
}a[105];
int cmp(T a,T b)
{
    return a.va>b.va||a.va==b.va&&a.s<b.s;
}
int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        int n,m;
        cin>>n>>m;
        for(int i=0;i<n;i++)cin>>a[i].s>>a[i].va;
        sort(a,a+n,cmp);
        long long sum=0;
        for(int i=0;i<m;i++)
            sum+=(m-i)*1LL*a[i].va;
        cout<<sum;
        for(int i=0;i<m;i++)cout<<" "<<a[i].s;
        cout<<"\n";
    }
    return 0;
}
Lucky 7
Time Limit: 1 Second       Memory Limit: 65536 KB

BaoBao has just found a positive integer sequence  of length  from his left pocket and another positive integer  from his right pocket. As number 7 is BaoBao''s favorite number, he considers a positive integer  lucky if  is divisible by 7. He now wants to select an integer  from the sequence such that  is lucky. Please tell him if it is possible.

Input

There are multiple test cases. The first line of the input is an integer  (about 100), indicating the number of test cases. For each test case:

The first line contains two integers  and  (), indicating the length of the sequence and the positive integer in BaoBao''s right pocket.

The second line contains  positive integers  (), indicating the sequence.

Output

For each test case output one line. If there exists an integer  such that  and  is lucky, output "Yes" (without quotes), otherwise output "No" (without quotes).

Sample Input

4
3 7
4 5 6
3 7
4 7 6
5 2
2 5 2 5 2
4 26
100 1 2 4

Sample Output

No
Yes
Yes
Yes

Hint

For the first sample test case, as 4 + 7 = 11, 5 + 7 = 12 and 6 + 7 = 13 are all not divisible by 7, the answer is "No".

For the second sample test case, BaoBao can select a 7 from the sequence to get 7 + 7 = 14. As 14 is divisible by 7, the answer is "Yes".

For the third sample test case, BaoBao can select a 5 from the sequence to get 5 + 2 = 7. As 7 is divisible by 7, the answer is "Yes".

For the fourth sample test case, BaoBao can select a 100 from the sequence to get 100 + 26 = 126. As 126 is divisible by 7, the answer is "Yes".

加上一个数是不是7的倍数,直接做

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        int n,b;
        cin>>n>>b;
        int f=0;
        for(int i=0,x;i<n;i++)
        {
            cin>>x;
            if((x+b)%7==0)f=1;
        }
        cout<<(f?"Yes":"No")<<"\n";
    }
    return 0;
}

 

K
Mahjong Sorting
Time Limit: 1 Second       Memory Limit: 65536 KB

DreamGrid has just found a set of Mahjong with  suited tiles and a White Dragon tile in his pocket. Each suited tile has a suit (Character, Bamboo or Dot) and a rank (ranging from 1 to ), and there is exactly one tile of each rank and suit combination.

Character tiles whose rank ranges from 1 to 9

Bamboo tiles whose rank ranges from 1 to 9

Dot tiles whose rank ranges from 1 to 9

White Dragon tile

As DreamGrid is bored, he decides to play with these tiles. He first selects one of the  suited tiles as the "lucky tile", then he picks  tiles from the set of  tiles and sorts these  tiles with the following rules:

  • The "lucky tile", if contained in the  tiles, must be placed in the leftmost position.

  • For two tiles  and  such that neither of them is the "lucky tile", if

    •  is a Character tile and  is a Bamboo tile, or

    •  is a Character tile and  is a Dot tile, or

    •  is a Bamboo tile and  is a Dot tile, or

    •  and  have the same suit and the rank of  is smaller than the rank of ,

    then  must be placed to the left of .

     

 

White Dragon tile is a special tile. If it''s contained in the  tiles, it''s considered as the original (not-lucky) version of the lucky tile during the sorting. For example, consider the following sorted tiles, where "3 Character" is selected as the lucky tile. White Dragon tile, in this case, is considered to be the original not-lucky version of "3 Character" and should be placed between "2 Character" and "4 Character".

As DreamGrid is quite forgetful, he immediately forgets what the lucky tile is after the sorting! Given  sorted tiles, please tell DreamGrid the number of possible lucky tiles.

Input

There are multiple test cases. The first line of the input contains an integer , indicating the number of test cases. For each test case:

The first line contains two integers  and  (), indicating the number of sorted tiles and the maximum rank of suited tiles.

For the next  lines, the -th line describes the -th sorted tile counting from left to right. The line begins with a capital letter  (), indicating the suit of the -th tile:

  • If , then an integer  () follows, indicating that it''s a Character tile with rank ;

  • If , then an integer  () follows, indicating that it''s a Bamboo tile with rank ;

  • If , then an integer  () follows, indicating that it''s a Dot tile with rank ;

  • If , then it''s a White Drangon tile.

 

It''s guaranteed that there exists at least one possible lucky tile, and the sum of  in all test cases doesn''t exceed .

Output

For each test case output one line containing one integer, indicating the number of possible lucky tiles.

Sample Input

4
3 9
C 2
W
C 4
6 9
C 2
C 7
W
B 3
B 4
D 2
3 100
C 2
W
C 9
3 9
C 1
B 2
D 3

Sample Output

2
4
7
25

Hint

For the first sample, "2 Character" and "3 Character" are possible lucky tiles.

For the second sample, "8 Character", "9 Character", "1 Bamboo" and "2 Bamboo" are possible lucky tiles.

 自己菜做不出来,要把所有的情况都分析到,我太菜了,这个题不想再做了

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N],n,m;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int f=0,ans;
        scanf("%d%d",&n,&m);
        a[n+1]=3*m+1;
        for(int i=1; i<=n; i++)
        {
            getchar();
            char c=getchar();
            if(c!=''W'')
            {
                scanf("%d",&a[i]);
                if(c==''B'')a[i]+=m;
                if(c==''D'')a[i]+=2*m;
            }
            else f=i;
        }
        if(n==1)ans=3*m;
        else
        {
            if(f==0)
                if(a[1]>a[2])ans=1;
                else ans=3*m-n+1;
            else
            {
                if(f==1)ans=a[2]-1;
                else
                {
                    if(a[1]>a[2]&&f!=2)ans=1;
                    else ans=a[f+1]-a[f-1]-(f!=2);
                }
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}

 

 D
Sequence Swapping
Time Limit: 1 Second       Memory Limit: 65536 KB

BaoBao has just found a strange sequence {<>, <>, , <>} of length  in his pocket. As you can see, each element <> in the sequence is an ordered pair, where the first element  in the pair is the left parenthesis ''('' or the right parenthesis '')'', and the second element  in the pair is an integer.

As BaoBao is bored, he decides to play with the sequence. At the beginning, BaoBao''s score is set to 0. Each time BaoBao can select an integer , swap the -th element and the -th element in the sequence, and increase his score by , if and only if  ''('' and  '')''.

BaoBao is allowed to perform the swapping any number of times (including zero times). What''s the maximum possible score BaoBao can get?

Input

There are multiple test cases. The first line of the input contains an integer , indicating the number of test cases. For each test case:

The first line contains an integer  (), indicating the length of the sequence.

The second line contains a string  () consisting of ''('' and '')''. The -th character in the string indicates , of which the meaning is described above.

The third line contains  integers  (). Their meanings are described above.

It''s guaranteed that the sum of  of all test cases will not exceed .

Output

For each test case output one line containing one integer, indicating the maximum possible score BaoBao can get.

Sample Input

4
6
)())()
1 3 5 -1 3 2
6
)())()
1 3 5 -100 3 2
3
())
1 -1 -1
3
())
-1 -1 -1

Sample Output

24
21
0
2

Hint

For the first sample test case, the optimal strategy is to select  in order.

For the second sample test case, the optimal strategy is to select  in order.

 这个dp就是去找(,找到它最右可以到达的位置
 然后你可以找一个这个)前一个),保证他也最优 
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
typedef long long ll;
char s[N];
ll v[N],dp[N][N],sum[N],F[N],nxt[N];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,f=0,tot=1;
        scanf("%d%s",&n,s+1);
        for(int i=1; i<=n; i++)scanf("%lld",&v[i]);
        for(int i=n; i>0; i--)if(s[i]==''('')F[tot++]=i;
        for(int i=1; i<=n; i++) sum[i]=sum[i-1]+(s[i]=='')''?v[i]:0);
        memset(nxt,0,sizeof(nxt));
        for(int i=1; i<=n; i++)
            if(s[i]=='')'')
            {
                if(f) nxt[f]=i;
                f=i;
            }
        for(int i=1; i<=n; i++) dp[i][0]=-(1LL<<60);
        ll ans=0;
        for(int i=1; i<tot; i++)
        {
            for(int j=F[i]+1; j<=n; j++)
                if(s[j]=='')'') dp[i][j]=v[F[i]]*(sum[j]-sum[F[i]])+dp[i-1][j];
            for(int j=n; j>=F[i]; j--)
                if(s[j]=='')'') dp[i][j]=max(dp[i][nxt[j]],dp[i][j]);
            for(int j=F[i]-1; j>=1; j--)
                if(s[j]=='')'') dp[i][j]=max(dp[i-1][j],dp[i][nxt[j]]);
            for(int j=1; j<=n; j++) if(s[j]=='')'')ans=max(ans,dp[i][j]);
        }
        printf("%lld\n",ans);
    }
    return 0;
}

使用滚动数组优化

#include<bits/stdc++.h>
using namespace std;
const int N=1005;
typedef long long ll;
char s[N];
ll v[N],dp[2][N],sum[N],F[N],nxt[N];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,f=0,tot=1,cur=0;
        scanf("%d%s",&n,s+1);
        for(int i=1; i<=n; i++)scanf("%lld",&v[i]);
        for(int i=n; i>0; i--)if(s[i]==''('')F[tot++]=i;
        for(int i=1; i<=n; i++) sum[i]=sum[i-1]+(s[i]=='')''?v[i]:0);
        memset(nxt,0,sizeof(nxt));
        for(int i=1; i<=n; i++)
            if(s[i]=='')'')
            {
                if(f) nxt[f]=i;
                f=i;
            }
        for(int i=1; i<=n; i++) dp[1][i]=dp[0][i]=0;
        dp[0][0]=dp[1][0]=-(1LL<<60);
        ll ans=0;
        for(int i=1; i<tot; i++)
        {
            for(int j=F[i]+1; j<=n; j++)
                if(s[j]=='')'') dp[cur][j]=v[F[i]]*(sum[j]-sum[F[i]])+dp[cur^1][j];
            for(int j=n; j>=F[i]; j--)
                if(s[j]=='')'') dp[cur][j]=max(dp[cur][nxt[j]],dp[cur][j]);
            for(int j=F[i]-1; j>=1; j--)
                if(s[j]=='')'') dp[cur][j]=max(dp[cur^1][j],dp[cur][nxt[j]]);
            for(int j=1; j<=n; j++) if(s[j]=='')'')ans=max(ans,dp[cur][j]);
            cur^=1;
        }
        printf("%lld\n",ans);
    }
    return 0;

 

Magic 12 Months
Time Limit: 1 Second       Memory Limit: 65536 KB

It''s New Year''s Eve, and it''s also the best time of the year to play the card game Magic 12 Months to pray for good luck of the coming year. BaoBao has just found a deck of standard 52 playing cards (without Jokers) in his pocket and decides to play the game. The rules are as follows:

  1. Setup

    1. Remove the four ''K''s from the 52 cards.

    2. Shuffle the remaining 48 cards and divide them face down into 12 piles (4 cards per pile) with equal probability.

  2. Gameplay

    1. Let .

    2. Flip the card on the top of the -th pile, check its rank , and discard the card.

    3. If  is a number, let ; If , let ; If , let ; If , let .

    4. If the -th pile is empty, the game ends; Otherwise go back to step 2.2.

When the game ends, having all the 4 cards of rank  flipped and discarded indicates that the -th month in the coming year is a lucky month.

BaoBao is in the middle of the game and has discarded  cards. He wants to know the probability that the -th month of the coming year is a lucky month for all  when the game ends. Given these  cards, please help him calculate the answer.

Input

There are multiple test cases. The first line of input contains an integer  (about 100) -- the number of test cases. For each test case:

The first and only line contains an integer  () -- the number of flipped cards, followed by the rank of the  cards  () separated by a space in the order they are flipped. It''s guaranteed that the input describes a valid and possible situation of the game.

Output

For each test case output one line containing 12 numbers separated by a space, where the -th number indicates the probability that the -th month of the coming year is a lucky month.

You should output a probability in its simplest fraction form  where  and  are coprime. Specifically, if the probability equals 0, you should output 0; If the probability equals 1, you should output 1.

Please, DO NOT output extra spaces at the end of each line, or your answer may be considered incorrect!

Sample Input

3
30 9 Q 10 J Q 10 J 10 J J 8 5 7 6 5 7 6 7 6 6 3 A 2 4 A 2 4 2 4 4
0
7 2 A 3 A 4 A A

Sample Output

1 2/3 2/5 1 1/2 1 2/3 2/5 2/5 2/3 1 1/2
1 1/2 1/2 1/2 1/2 1/2 1/2 1/2 1/2 1/2 1/2 1/2
1 0 0 0 0 0 0 0 0 0 0 0

 

 

想到了和第一堆有关,但是还没推出来

#include<bits/stdc++.h>
using namespace std;
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
typedef long long ll;
ll C(int n,int m)
{
    if(m>n)return 0;
    ll ans=1;
    for(int i=n-m+1; i<=n; i++)ans*=i;
    for(int i=2; i<=m; i++)ans/=i;
    return ans;
}
int a[15];
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        for(int i=1; i<=12; i++)a[i]=4;
        int n;
        cin>>n;
        string s;
        for(int i=0,x; i<n; i++)
        {
            cin>>s;
            if(s=="10")x=10;
            else if(s=="A")x=1;
            else if(s=="J")x=11;
            else if(s=="Q")x=12;
            else x=s[0]-48;
            a[x]--;
        }
        cout<<1;
        for(int i=2; i<=12; i++)
        {
            //dbg(a[i]);
            if(!a[i])cout<<" 1";
            else if(!a[1])cout<<" 0";
            else
            {
                int m=48-n;
                ll B=C(m,a[1])*C(m-a[1],a[i]),A=0;
                for(int j=a[1]; j<=m; j++)A+=C(j-1,a[1]-1)*C(j-a[1],a[i]);
                ll d=__gcd(A,B);
                if(!A)cout<<" 0";
                else if(A==B)cout<<" 1";
                else cout<<" "<<A/d<<"/"<<B/d;
            }
        }
        cout<<"\n";
    }
    return 0;
}

 

AP controller-centralized management-support-IPQ6010-IPQ5018-IPQ4019 motherboard

AP controller-centralized management-support-IPQ6010-IPQ5018-IPQ4019 motherboard

AP controller-centralized management-support-IPQ6010-IPQ5018-IPQ4019 motherboard
AP controller is a network device used to manage and control multiple APs in a wireless network. It plays an important role in enterprises or large organizations to centrally manage and configure APs, providing a higher level of network control and monitoring. The following are the main functions of the AP controller:
Centralized management:
AP controller allows centralized management and configuration of a large number of APs. Administrators can configure all AP parameters at one time through the controller, such as wireless network name (SSID), security settings, transmission power, etc. This simplifies network administration and improves configuration consistency.
cyber security:
AP controller can provide advanced network security functions. It centrally manages and enforces security policies such as user authentication, access control lists (ACLs), and encryption settings. Administrators can use the controller to secure the network from unauthorized access and malicious activity.
load balancing:
The AP controller can automatically perform load balancing according to the network load. It can monitor the number of connections and transmission rates of APs, and dynamically allocate clients to available APs to avoid performance degradation caused by overloading of an AP. This helps improve the throughput and reliability of the overall network.
Failure detection and failover:
The AP controller can monitor the status and connection quality of the AP. If an AP fails or the quality of the connection degrades, the controller can quickly detect it and take appropriate action. It can automatically switch clients to other available APs to ensure network connectivity and availability.
statistic and analysis:
The AP controller can collect and analyze data related to the wireless network. It provides statistics on client connections, data traffic, signal strength, and network performance. This data can help administrators understand network usage, bottlenecks, and opportunities for improvement.
Below is a schematic diagram showing the relationship between the AP controller and multiple APs:

In the schematic diagram, the AP controller is located at the core of the network and is connected to multiple APs. Administrators can centrally manage and configure APs through the controller to achieve more efficient network control and monitoring.
Exciting news! Introducing Wallys AP Controller, your key to simplified and efficient network management. Say goodbye to complexity and hello to streamlined operations. Explore the limitless potential of our AP Controller and unlock the power of efficient network man agement.

关于The Swell by Ripple Conference in 2018的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于20+ Rsync command’s switches and common usages with examples – Unix/Linux--reference、2018-2019 ICPC Southwestern European Regional Programming Contest (SWERC 2018)、2018浙江省赛(ACM) The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple、AP controller-centralized management-support-IPQ6010-IPQ5018-IPQ4019 motherboard的相关知识,请在本站寻找。

本文标签: