You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.6 KiB
67 lines
1.6 KiB
2 years ago
|
#include <bits/stdc++.h>
|
||
|
|
||
|
using namespace std;
|
||
|
<<<<<<< HEAD
|
||
|
int n, m;
|
||
|
int a[11];
|
||
|
void dfs(int u, int k, int l) {
|
||
|
if (k == 0 && u == m+1) {
|
||
|
for (int i = 1; i <= m; i++) cout << a[i] << " ";
|
||
|
cout << endl;
|
||
|
return;
|
||
|
=======
|
||
|
int w[5];
|
||
|
bool check(string addr){
|
||
|
memset(w, -1, sizeof w);
|
||
|
sscanf(addr.c_str(), "%d.%d.%d.%d:%d", &w[0], &w[1], &w[2], &w[3], &w[4]);
|
||
|
|
||
|
char str[100];
|
||
|
sprintf(str, "%d.%d.%d.%d:%d", w[0], w[1], w[2], w[3], w[4]);
|
||
|
if (str != addr) return false;
|
||
|
for (int i = 0; i < 5; i++){
|
||
|
if (w[i] < 0) return false;
|
||
|
if (i < 4 && w[i] > 255) return false;
|
||
|
if (i == 4 && w[i] > 65535) return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
int main() {
|
||
|
int n;
|
||
|
cin >> n;
|
||
|
unordered_map<string, int> hash;
|
||
|
for (int i = 1; i <= n; i++){
|
||
|
string type, addr;
|
||
|
cin >> type >> addr;
|
||
|
if(type=="Server"){
|
||
|
if(!check(addr))
|
||
|
puts("ERR");
|
||
|
else if(hash.count(addr))
|
||
|
puts("FAIL");
|
||
|
else{
|
||
|
hash[addr] = i;
|
||
|
puts("OK");
|
||
|
}
|
||
|
}else{
|
||
|
if(!check(addr))
|
||
|
puts("ERR");
|
||
|
else if(!hash.count(addr))
|
||
|
puts("FAIL");
|
||
|
else
|
||
|
cout << hash[addr] << endl;
|
||
|
}
|
||
|
>>>>>>> 2767296e499e316f431960114b24a1de57ecdb85
|
||
|
}
|
||
|
|
||
|
if (u >= m + 1) return;
|
||
|
if (k == 0) return;
|
||
|
|
||
|
for (int i = l+1; i <= k; i++){
|
||
|
a[u ] = i;
|
||
|
dfs(u + 1, k - i, i);
|
||
|
}
|
||
|
}
|
||
|
int main() {
|
||
|
cin >> n >> m;
|
||
|
dfs(1, n, 0);
|
||
|
return 0;
|
||
|
}
|