✅ (wip) P7911 莫名其妙不一样 https://www.luogu.com.cn/problem/P7911
This commit is contained in:
parent
64a7875d1d
commit
318c907321
@ -21,4 +21,5 @@ add_executable(Playground
|
||||
state-compress-dp/main.cpp
|
||||
sudoku/main.cc
|
||||
take-most-space-element/main.cc
|
||||
walking-in-maze/main.cc)
|
||||
walking-in-maze/main.cc
|
||||
network-connection/main.cpp)
|
||||
|
18
add-oil/main.cc
Normal file
18
add-oil/main.cc
Normal file
@ -0,0 +1,18 @@
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
int main() {
|
||||
int num = 0;
|
||||
string str;
|
||||
cin >> str;
|
||||
if (atoi(str[0]) > 2) {
|
||||
num++;
|
||||
}
|
||||
bool is_feb = atoi(str[1]) == 2;
|
||||
int days = stoi(str[3].to_string()+str[4].to_string());
|
||||
if (days > 30 || (is_feb && days > 28)) {
|
||||
num++;
|
||||
}
|
||||
cout << num << endl;
|
||||
}
|
6
network-connection/data.in
Normal file
6
network-connection/data.in
Normal file
@ -0,0 +1,6 @@
|
||||
5
|
||||
Server 192.168.1.1:8080
|
||||
Server 192.168.1.1:8080
|
||||
Client 192.168.1.1:8080
|
||||
Client 192.168.1.1:80
|
||||
Client 192.168.1.1:99999
|
11
network-connection/data2.in
Normal file
11
network-connection/data2.in
Normal file
@ -0,0 +1,11 @@
|
||||
10
|
||||
Server 192.168.1.1:80
|
||||
Client 192.168.1.1:80
|
||||
Client 192.168.1.1:8080
|
||||
Server 192.168.1.1:80
|
||||
Server 192.168.1.1:8080
|
||||
Server 192.168.1.999:0
|
||||
Client 192.168.1.1.8080
|
||||
Client 192.168.1.1:8080
|
||||
Client 192.168.1.1:80
|
||||
Client 192.168.1.999:0
|
102
network-connection/data3.in
Normal file
102
network-connection/data3.in
Normal file
@ -0,0 +1,102 @@
|
||||
100
|
||||
Server 249.217.185.41:28390
|
||||
Server 58.139.75.150:32916
|
||||
Server 164.132.230.103:2805
|
||||
Server 230.34.60.10:3192
|
||||
Server 8.158.211.70:45542
|
||||
Server 102.194.238.18:15088
|
||||
Server 101.59.241.186:52427
|
||||
Server 115.143.108.72:16537
|
||||
Server 161.221.13.212:52047
|
||||
Server 7.75.149.236:11770
|
||||
Server 108.220.137.165:26957
|
||||
Server 121.180.139.110:5392
|
||||
Server 12.214.2.248:41461
|
||||
Server 158.68.44.93:53435
|
||||
Server 97.63.72.59:35064
|
||||
Server 220.187.86.78:64381
|
||||
Server 59.29.128.91:2717
|
||||
Server 140.175.106.200:30566
|
||||
Server 245.233.205.228:55782
|
||||
Server 205.24.170.47:55248
|
||||
Server 103.60.29.80:37007
|
||||
Server 223.76.148.124:12954
|
||||
Server 80.112.212.73:31448
|
||||
Server 244.221.32.22:12816
|
||||
Server 140.140.178.160:24540
|
||||
Server 98.185.111.15:42673
|
||||
Server 219.249.194.5:48754
|
||||
Server 80.139.152.191:47985
|
||||
Server 103.98.92.158:15313
|
||||
Server 112.94.91.98:9353
|
||||
Server 203.152.232.46:8570
|
||||
Server 64.7.69.2:53535
|
||||
Server 70.77.237.205:48715
|
||||
Server 63.190.182.194:22734
|
||||
Server 167.198.175.203:52975
|
||||
Server 231.18.52.239:65074
|
||||
Server 30.65.214.84:14567
|
||||
Server 185.76.45.166:49771
|
||||
Server 173.43.69.196:13369
|
||||
Server 85.11.251.17:65259
|
||||
Server 151.72.42.94:5341
|
||||
Server 169.96.64.212:12779
|
||||
Server 114.141.130.157:47652
|
||||
Server 217.0.167.240:30040
|
||||
Server 187.253.126.242:22788
|
||||
Server 33.61.94.253:4080
|
||||
Server 254.44.190.153:24278
|
||||
Server 146.243.101.66:32070
|
||||
Server 80.79.84.224:49562
|
||||
Server 63.81.148.7:28810
|
||||
Client 81.235.246.73:18305
|
||||
Client 59.29.128.91:2717
|
||||
Client 33.61.94.253:4080
|
||||
Client 220.120.144.227:3377
|
||||
Client 64.7.69.2:53535
|
||||
Client 58.139.75.150:32916
|
||||
Client 187.253.126.242:22788
|
||||
Client 100.157.115.70:35513
|
||||
Client 102.194.238.18:15088
|
||||
Client 103.60.29.80:37007
|
||||
Client 140.140.178.160:24540
|
||||
Client 203.152.232.46:8570
|
||||
Client 63.190.182.194:22734
|
||||
Client 231.18.52.239:65074
|
||||
Client 54.38.47.208:49299
|
||||
Client 161.221.13.212:52047
|
||||
Client 219.146.191.132:46238
|
||||
Client 219.249.194.5:48754
|
||||
Client 63.81.148.7:28810
|
||||
Client 103.98.92.158:15313
|
||||
Client 121.180.139.110:5392
|
||||
Client 173.43.69.196:13369
|
||||
Client 244.221.32.22:12816
|
||||
Client 195.217.161.202:296
|
||||
Client 200.1.184.95:61373
|
||||
Client 217.0.167.240:30040
|
||||
Client 239.182.127.128:4536
|
||||
Client 49.50.201.196:52090
|
||||
Client 30.65.214.84:14567
|
||||
Client 61.35.102.136:21585
|
||||
Client 12.214.2.248:41461
|
||||
Client 194.36.60.51:11079
|
||||
Client 37.61.94.253:4080
|
||||
Client 34.213.35.199:47886
|
||||
Client 8.158.211.70:45542
|
||||
Client 63.81.148.0:28810
|
||||
Client 209.249.194.5:48754
|
||||
Client 7.75.149.236:11770
|
||||
Client 228.171.11.185:11107
|
||||
Client 95.18.63.74:30162
|
||||
Client 116.241.162.73:63458
|
||||
Client 249.207.124.200:48831
|
||||
Client 223.76.148.124:12954
|
||||
Client 70.77.237.205:48715
|
||||
Client 35.29.90.180:59047
|
||||
Client 164.132.230.103:2805
|
||||
Client 59.29.128.91:27178
|
||||
Client 86.190.70.70:20998
|
||||
Client 59.29.128.91:2517
|
||||
Client 139.200.25.104:52480
|
||||
|
100
network-connection/data3.out
Normal file
100
network-connection/data3.out
Normal file
@ -0,0 +1,100 @@
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
FAIL
|
||||
17
|
||||
46
|
||||
FAIL
|
||||
32
|
||||
2
|
||||
45
|
||||
FAIL
|
||||
6
|
||||
21
|
||||
25
|
||||
31
|
||||
34
|
||||
36
|
||||
FAIL
|
||||
9
|
||||
FAIL
|
||||
27
|
||||
50
|
||||
29
|
||||
12
|
||||
39
|
||||
24
|
||||
FAIL
|
||||
FAIL
|
||||
44
|
||||
FAIL
|
||||
FAIL
|
||||
37
|
||||
FAIL
|
||||
13
|
||||
FAIL
|
||||
FAIL
|
||||
FAIL
|
||||
5
|
||||
FAIL
|
||||
FAIL
|
||||
10
|
||||
FAIL
|
||||
FAIL
|
||||
FAIL
|
||||
FAIL
|
||||
22
|
||||
33
|
||||
FAIL
|
||||
3
|
||||
FAIL
|
||||
FAIL
|
||||
FAIL
|
||||
FAIL
|
1002
network-connection/data4.in
Normal file
1002
network-connection/data4.in
Normal file
File diff suppressed because it is too large
Load Diff
1000
network-connection/data4.out
Normal file
1000
network-connection/data4.out
Normal file
File diff suppressed because it is too large
Load Diff
57
network-connection/main.cpp
Normal file
57
network-connection/main.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#include <cstring>
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool validate_addr(const string &addr) {
|
||||
if (addr.size() > 22) return false;
|
||||
int ip_parts[4];
|
||||
int port;
|
||||
sscanf(addr.c_str(), "%d.%d.%d.%d:%d", &ip_parts[0], &ip_parts[1], &ip_parts[2], &ip_parts[3], &port);
|
||||
char out[35];
|
||||
sprintf(out, "%d.%d.%d.%d:%d", ip_parts[0], ip_parts[1], ip_parts[2], ip_parts[3], port);
|
||||
if (strlen(out) != addr.size()) return false; // Leading 0
|
||||
|
||||
if (port > 65536 || port < 0) return false;
|
||||
|
||||
for (int ip_part: ip_parts) {
|
||||
if (ip_part > 256 || ip_part < 0) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
map<string, int> servers;
|
||||
cin >> n;
|
||||
for (int i = 0; i < n; i++) {
|
||||
string mode, t;
|
||||
cin >> mode >> t;
|
||||
|
||||
if (!validate_addr(t)) {
|
||||
cout << "ERR" << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mode == "Server") {
|
||||
if (servers.find(t) == servers.end()) {
|
||||
// Not found, good to go
|
||||
servers[t] = i + 1;
|
||||
cout << "OK" << endl;
|
||||
} else {
|
||||
cout << "FAIL" << endl;
|
||||
}
|
||||
}
|
||||
if (mode == "Client") {
|
||||
if (servers.find(t) == servers.end()) {
|
||||
cout << "FAIL" << endl;
|
||||
} else {
|
||||
cout << servers[t] << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
2
second-large-number/data.in
Normal file
2
second-large-number/data.in
Normal file
@ -0,0 +1,2 @@
|
||||
100
|
||||
40 32 2 42 47 7 24 14 11 7 19 3 44 49 44 32 4 28 4 48 4 7 41 32 42 41 27 4 20 40 44 30 13 44 8 10 16 46 50 18 20 15 4 32 22 25 10 2 17 10 49 4 47 10 41 28 3 3 26 22 13 40 29 14 9 1 43 21 19 20 10 12 40 6 14 9 14 46 25 50 17 45 1 30 5 37 8 5 47 43 39 12 25 1 40 20 2 10 14 21
|
24
second-large-number/main.cc
Normal file
24
second-large-number/main.cc
Normal file
@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
int main() {
|
||||
int k;
|
||||
cin >> k;
|
||||
vector<int> arr;
|
||||
for (int i = 0; i < k; i++) {
|
||||
int t;
|
||||
cin >> t;
|
||||
arr.push_back(t);
|
||||
}
|
||||
auto ptr = unique(arr.begin(), arr.end());
|
||||
arr.erase(ptr, arr.end());
|
||||
if (arr.size() <= 2) {
|
||||
cout << -1 << endl;
|
||||
return 0;
|
||||
}
|
||||
sort(arr.begin(), arr.end());
|
||||
arr.insert(arr.begin(), 1, 0);
|
||||
auto kp = arr.size()-1;
|
||||
cout << max(arr[kp - 2], arr[kp] % arr[kp - 1]) << endl;
|
||||
}
|
Loading…
Reference in New Issue
Block a user