QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#688263 | #2937. CIDR | kevinyang# | AC ✓ | 18ms | 3848kb | C++17 | 950b | 2024-10-30 01:47:53 | 2024-10-30 01:47:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int parse(string s){
for(int i = 0; i<s.size(); i++){
if(s[i] == '.'){
s[i] = ' ';
}
}
istringstream iss{s};
int cur = 0;
int temp;
while(iss >> temp){
cur*=256;
cur+=temp;
}
return cur;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
vector<int>a(n);
for(int i = 0; i<n; i++){
string s;
cin >> s;
a[i] = parse(s);
}
int ans = 0;
int cur = 0;
for(int i = 31; i>=0; i--){
set<int>s;
cur+=1LL<<i;
for(int j = 0; j<n; j++){
s.insert(a[j]&cur);
}
if(s.size() > 1){
break;
}
ans++;
}
if(ans == 0){
cout << "32\n";
}
else{
cout << ans << '\n';
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3808kb
input:
4 10.0.0.1 10.0.0.24 10.0.0.8 10.0.0.16
output:
27
result:
ok single line: '27'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
5 10.0.0.1 10.0.0.24 10.0.0.8 10.1.0.1 10.0.0.16
output:
15
result:
ok single line: '15'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
2 127.0.0.1 127.0.0.53
output:
26
result:
ok single line: '26'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
3 0.0.0.128 0.0.0.3 0.0.128.5
output:
16
result:
ok single line: '16'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
5 123.123.123.123 123.123.123.123 123.123.123.123 123.123.123.123 123.123.123.123
output:
32
result:
ok single line: '32'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
5 128.0.0.1 192.192.192.1 224.255.255.255 240.1.1.1 248.3.243.254
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 18ms
memory: 3596kb
input:
65535 103.123.35.198 103.60.152.105 103.51.72.115 103.176.220.81 103.73.92.255 103.232.148.74 103.85.88.236 103.142.31.41 103.232.124.205 103.27.88.186 103.126.215.171 103.177.65.242 103.183.30.251 103.226.169.227 103.69.225.70 103.95.0.124 103.208.98.194 103.32.8.84 103.177.39.248 103.22.35.27 103....
output:
8
result:
ok single line: '8'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
7 14.137.189.173 14.149.194.214 14.182.230.252 14.221.73.48 14.200.72.103 14.241.160.91 14.231.239.0
output:
9
result:
ok single line: '9'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
2 117.85.58.182 117.89.73.61
output:
12
result:
ok single line: '12'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
18 135.232.24.34 135.247.93.55 135.233.112.52 135.254.247.161 135.227.176.227 135.231.127.135 135.232.23.182 135.239.212.207 135.228.10.30 135.228.181.154 135.239.39.174 135.247.106.210 135.243.46.115 135.251.208.216 135.228.174.6 135.225.47.33 135.227.92.241 135.227.158.35
output:
11
result:
ok single line: '11'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
16 252.114.133.31 252.120.53.254 252.113.104.46 252.124.37.122 252.112.36.254 252.119.149.234 252.125.159.78 252.117.95.181 252.112.223.39 252.116.160.106 252.119.91.243 252.120.247.74 252.123.253.162 252.112.204.39 252.119.238.235 252.127.174.133
output:
12
result:
ok single line: '12'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
16 53.11.131.84 53.12.85.205 53.12.188.59 53.14.171.2 53.11.192.159 53.15.234.175 53.10.123.218 53.8.110.166 53.9.25.208 53.13.216.204 53.12.12.201 53.12.6.158 53.14.248.147 53.14.145.232 53.12.60.156 53.8.96.194
output:
13
result:
ok single line: '13'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
22 134.109.246.172 134.108.86.176 134.109.193.79 134.108.213.212 134.108.247.26 134.109.29.67 134.109.205.30 134.108.244.188 134.109.233.106 134.109.188.9 134.108.163.65 134.110.53.25 134.109.194.170 134.108.38.150 134.110.138.230 134.110.126.230 134.110.209.152 134.110.75.133 134.110.105.149 134.10...
output:
14
result:
ok single line: '14'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
25 141.234.138.3 141.234.30.210 141.235.88.220 141.235.198.159 141.234.127.148 141.234.16.62 141.234.40.57 141.234.118.65 141.234.102.238 141.235.233.137 141.235.76.21 141.235.94.9 141.235.6.204 141.235.25.51 141.234.82.197 141.234.240.54 141.234.213.60 141.234.246.7 141.235.37.79 141.234.151.230 14...
output:
15
result:
ok single line: '15'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
31 59.169.53.230 59.169.3.198 59.169.97.231 59.169.124.219 59.169.141.201 59.169.128.186 59.169.213.183 59.169.84.104 59.169.0.78 59.169.229.246 59.169.124.162 59.169.118.143 59.169.76.228 59.169.102.43 59.169.194.164 59.169.170.237 59.169.108.247 59.169.219.215 59.169.253.179 59.169.93.45 59.169.17...
output:
16
result:
ok single line: '16'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
6 113.247.156.28 113.247.225.47 113.247.241.184 113.247.156.214 113.247.182.230 113.247.198.32
output:
17
result:
ok single line: '17'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
9 71.55.66.194 71.55.83.180 71.55.105.193 71.55.104.237 71.55.86.89 71.55.84.174 71.55.85.228 71.55.114.48 71.55.82.97
output:
18
result:
ok single line: '18'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
22 28.104.166.27 28.104.181.143 28.104.172.62 28.104.182.114 28.104.168.65 28.104.172.4 28.104.180.255 28.104.182.175 28.104.172.44 28.104.175.52 28.104.187.3 28.104.176.27 28.104.171.80 28.104.188.50 28.104.161.211 28.104.168.39 28.104.179.24 28.104.167.243 28.104.165.76 28.104.175.245 28.104.170.1...
output:
19
result:
ok single line: '19'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
8 87.58.55.89 87.58.62.100 87.58.57.136 87.58.49.138 87.58.48.198 87.58.60.154 87.58.52.206 87.58.54.225
output:
20
result:
ok single line: '20'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
19 42.136.105.84 42.136.106.106 42.136.109.16 42.136.106.83 42.136.105.25 42.136.105.61 42.136.105.135 42.136.108.28 42.136.105.88 42.136.108.215 42.136.104.78 42.136.107.43 42.136.108.254 42.136.107.103 42.136.107.30 42.136.106.74 42.136.107.92 42.136.109.212 42.136.107.75
output:
21
result:
ok single line: '21'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
24 212.133.228.164 212.133.231.118 212.133.231.0 212.133.228.46 212.133.228.60 212.133.231.154 212.133.228.252 212.133.231.30 212.133.229.195 212.133.230.8 212.133.228.114 212.133.228.45 212.133.231.25 212.133.230.197 212.133.229.71 212.133.228.86 212.133.228.76 212.133.229.99 212.133.229.174 212.13...
output:
22
result:
ok single line: '22'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
7 238.80.218.117 238.80.219.204 238.80.219.183 238.80.219.135 238.80.219.68 238.80.218.92 238.80.218.253
output:
23
result:
ok single line: '23'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
8 24.2.139.58 24.2.139.222 24.2.139.135 24.2.139.88 24.2.139.161 24.2.139.143 24.2.139.202 24.2.139.206
output:
24
result:
ok single line: '24'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
20 21.37.199.149 21.37.199.254 21.37.199.219 21.37.199.249 21.37.199.172 21.37.199.254 21.37.199.171 21.37.199.133 21.37.199.160 21.37.199.196 21.37.199.253 21.37.199.141 21.37.199.185 21.37.199.201 21.37.199.196 21.37.199.192 21.37.199.141 21.37.199.160 21.37.199.189 21.37.199.209
output:
25
result:
ok single line: '25'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
3 91.94.93.207 91.94.93.242 91.94.93.207
output:
26
result:
ok single line: '26'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
2 231.58.168.41 231.58.168.62
output:
27
result:
ok single line: '27'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
8 140.216.226.148 140.216.226.152 140.216.226.147 140.216.226.157 140.216.226.149 140.216.226.146 140.216.226.152 140.216.226.154
output:
28
result:
ok single line: '28'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
8 204.193.72.235 204.193.72.239 204.193.72.237 204.193.72.232 204.193.72.236 204.193.72.237 204.193.72.237 204.193.72.236
output:
29
result:
ok single line: '29'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
10 65.134.196.253 65.134.196.254 65.134.196.253 65.134.196.253 65.134.196.253 65.134.196.253 65.134.196.255 65.134.196.255 65.134.196.252 65.134.196.253
output:
30
result:
ok single line: '30'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
21 129.101.183.34 129.101.183.35 129.101.183.35 129.101.183.34 129.101.183.35 129.101.183.35 129.101.183.35 129.101.183.35 129.101.183.35 129.101.183.34 129.101.183.35 129.101.183.34 129.101.183.35 129.101.183.35 129.101.183.35 129.101.183.34 129.101.183.35 129.101.183.35 129.101.183.35 129.101.183....
output:
31
result:
ok single line: '31'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
18 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1
output:
32
result:
ok single line: '32'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
4 0.0.0.1 0.0.0.1 0.0.0.1 0.0.0.1
output:
32
result:
ok single line: '32'
Test #33:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
28 163.64.69.254 152.210.108.51 158.235.216.185 187.35.137.69 201.4.96.32 159.118.245.138 243.12.74.201 205.108.31.191 200.246.134.142 237.10.34.169 137.38.220.252 132.56.25.237 167.186.214.25 151.170.230.190 176.89.181.172 218.19.40.198 146.241.2.154 199.40.240.203 182.136.246.136 230.176.33.172 16...
output:
1
result:
ok single line: '1'
Test #34:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
6 221.231.53.9 243.49.123.185 214.123.56.45 252.211.13.194 238.85.4.254 223.127.152.77
output:
2
result:
ok single line: '2'
Test #35:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
22 236.235.184.13 229.64.137.218 238.107.114.112 246.18.149.9 233.120.163.200 246.38.72.137 237.189.123.199 249.210.89.116 240.57.113.79 224.174.126.97 224.251.74.63 230.194.103.215 231.94.160.13 226.200.75.174 253.118.208.82 249.16.152.151 253.134.48.242 231.230.5.198 237.247.221.172 245.146.142.52...
output:
3
result:
ok single line: '3'
Test #36:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
8 113.26.143.32 121.182.146.91 123.213.144.26 127.111.148.30 121.54.42.169 120.31.147.102 112.208.227.229 118.33.226.182
output:
4
result:
ok single line: '4'
Test #37:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
13 168.52.119.191 174.216.193.9 173.98.158.222 169.241.243.134 168.171.26.125 173.156.16.45 170.160.113.231 169.166.100.188 172.94.120.4 169.255.17.245 172.110.176.106 169.213.72.86 171.15.170.140
output:
5
result:
ok single line: '5'
Test #38:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
29 117.7.136.57 119.135.111.145 118.214.155.106 118.240.155.160 118.194.201.191 117.217.29.193 116.11.42.192 116.121.92.26 117.174.173.219 119.122.190.222 117.175.134.195 117.206.65.66 116.75.162.195 119.209.105.121 119.46.94.131 119.135.249.24 116.5.225.56 118.7.31.140 116.234.151.246 117.247.212.1...
output:
6
result:
ok single line: '6'