标签:type return ems 也有 2-2 sign pac def str
A
/*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define pb push_back using namespace std; typedef long long ll; typedef unsigned long long ull; const ll LLmaxn = 2e18; int main() { string a; cin >> a; int b=0, c=0; for (int i = 0; i < a.size(); i++) { if (a[i] == ‘-‘) { b++; } else { c++; } } //cout<<b<<" "<<c<<endl; if (c == 0) { cout << "YES" << endl; return 0; } if (b % c != 0) { cout << "NO" << endl; } else { cout << "YES" << endl; } return 0; }
B
解:
注意只要是上下对称或者是左右对称就可以使得 1-4 有一条路径的话 2-3 也有相对应的一条路径
剩下的就容易构造了
/*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define pb push_back using namespace std; typedef long long ll; typedef unsigned long long ull; const ll LLmaxn = 2e18; char ans[5][105]; int main() { int n, k; cin >> n >> k; for (int i = 1; i <= 4; i++) { for (int j = 1; j <= n; j++) { ans[i][j] = ‘.‘; } } int sum = (n - 2) * 2; if (k > sum) { cout << "NO" << endl; return 0; } cout << "YES" << endl; if (k % 2 == 0) { int cur = k; for (int j = 2; j <= n - 1 && cur; j++) { for (int i = 2; i <= 3 && cur; i++) { ans[i][j] = ‘#‘; cur--; } } } else { k--; ans[2][n / 2 + 1] = ‘#‘; for (int i = 2; i <= 3 && k; i++) { for (int j = 2; j <= n / 2 && k; j++) { ans[i][j] = ans[i][n - j + 1] = ‘#‘; k -= 2; } } } for (int i = 1; i <= 4; i++) { for (int j = 1; j <= n; j++) { cout << ans[i][j]; } cout << endl; } return 0; }
C
解:
可以用并查集维护每个点最小到达的地方 也因为N<=1E5,K<=256 直接暴力模拟也可以
/*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define pb push_back using namespace std; typedef long long ll; typedef unsigned long long ull; const ll LLmaxn = 2e18; char ans[5][105]; int main() { int n, k; cin >> n >> k; for (int i = 1; i <= 4; i++) { for (int j = 1; j <= n; j++) { ans[i][j] = ‘.‘; } } int sum = (n - 2) * 2; if (k > sum) { cout << "NO" << endl; return 0; } cout << "YES" << endl; if (k % 2 == 0) { int cur = k; for (int j = 2; j <= n - 1 && cur; j++) { for (int i = 2; i <= 3 && cur; i++) { ans[i][j] = ‘#‘; cur--; } } } else { k--; ans[2][n / 2 + 1] = ‘#‘; for (int i = 2; i <= 3 && k; i++) { for (int j = 2; j <= n / 2 && k; j++) { ans[i][j] = ans[i][n - j + 1] = ‘#‘; k -= 2; } } } for (int i = 1; i <= 4; i++) { for (int j = 1; j <= n; j++) { cout << ans[i][j]; } cout << endl; } return 0; }
D
卡题意
E
标签:type return ems 也有 2-2 sign pac def str
原文地址:https://www.cnblogs.com/Aragaki/p/9016076.html