• 欢迎光临~

# 2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest

#### 2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest

##### A - Alex Origami Squares

``````#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>

using namespace std;

string a, b, c;
int main()
{
freopen("alex.in", "r", stdin);
freopen("alex.out", "w", stdout);
cin.tie(0)->sync_with_stdio(0);
double a, b;
cin >> a >> b;
if (a < b)
swap(a, b);
double ans;
ans = a / 3;
if (a > b * 3)
ans = b;
ans = max(ans, b / 2);
printf("%.3lf", ans);
fclose(stdin);
fclose(stdout);
return 0;
}
``````
##### B - Black and White

``````#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>

using namespace std;
int main()
{
freopen("black.in", "r", stdin);
freopen("black.out", "w", stdout);
//  cin.tie(0)->sync_with_stdio(0);

int b, w;
cin >> b >> w;
if(b > w)
{
int t = b - w;
t++;
cout << t * 2 + (w - 1) * 2<< ' ' << 2 << endl;
while(t--) //先输出多出来的b-w+1个黑色区域
{
cout << '@' << '.' << endl;
cout << '.' << '.' << endl;
}
w--;
while(w--)//输出剩余部分
{
cout << '@' << '@' << endl;
cout << '.' << '.' << endl;
}
}
else
{
int t = w - b;
t++;
cout << t * 2 + (b - 1) * 2 << ' ' << 2 << endl;
while(t--)
{
cout << '.' << '@' << endl;
cout << '@' << '@' << endl;
}
b--;
while (b--) {
cout << '.' << '.' << endl;
cout << '@' << '@' << endl;

}
}
fclose(stdin);
fclose(stdout);
return 0;
}
``````
##### C - Concatenation

``````#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
typedef long long ll;
ll a[N];

map<char, ll> q;
map<char, ll> p;
int main()
{
freopen("concatenation.in", "r", stdin);
freopen("concatenation.out", "w", stdout);

string a, b;
cin >> a >> b;
ll len1 = a.size();
ll len2 = b.size();
for (int i = 1; i < len1; i++)
q[a[i]]++;
for (int i = 0; i + 1 < len2; i++)
p[b[i]]++;
ll ans = len1 * len2;
for (char i = 'a'; i <= 'z'; i++) {
ans -= p[i] * q[i];
}
cout << ans << endl;
fclose(stdin);
fclose(stdout);
return 0;
}

``````
##### E - Easy Arithmetic

``````#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>

using namespace std;

string a, b, c;
int main()
{
freopen("easy.in", "r", stdin);
freopen("easy.out", "w", stdout);
//  cin.tie(0)->sync_with_stdio(0);
string c;
cin >> c;
int l = c.size();
bool flag = 1;

for (int i = 0; i < l; i++) {
if (c[i] == '+')
flag = 1;
else if (c[i] == '-')
flag = 0;
else {
if (!flag && c[i - 1] != '-' && c[i - 1] != '+' && c[i] == '0')
cout << '+';
if (!flag && c[i - 1] != '-' && c[i - 1] != '+' && c[i] != '0') {
cout << '+';
flag = 1;
}
}
cout << c[i];
}
fclose(stdin);
fclose(stdout);
return 0;
}
``````
##### H - Hash Code Hacker

``````#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>

using namespace std;

string a, b, c;
int main()
{
freopen("hash.in", "r", stdin);
freopen("hash.out", "w", stdout);
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
for (int i = 0; i < n; i++)
a += 'B';
cout << a << endl;
for (int i = 0; i < n - 1; i++) {
a[i] = 'A';
a[i + 1] = 'a';
cout << a << endl;
a[i] = 'B';
a[i + 1] = 'B';
}

fclose(stdin);
fclose(stdout);
return 0;
}
``````
##### L - Lucky Chances

``````#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>

using namespace std;
int a[110][110], r, c, ans;
int dx[] = { 0, 0, 1, -1 }, dy[] = { 1, -1, 0, 0 };
bool find(int b, int x, int y, int n, int m)
{
x += n, y += m;
while (x >= 0 && y >= 0 && x <= r + 1 && y <= c + 1) {
if (b <= a[x][y])
return 0;
x += n, y += m;
}
return 1;
}
int main()
{
freopen("lucky.in", "r", stdin);
freopen("lucky.out", "w", stdout);
//  cin.tie(0)->sync_with_stdio(0);
cin >> r >> c;
for (int i = 1; i <= r; i++) {
for (int j = 1; j <= c; j++)
cin >> a[i][j];
}
for (int i = 1; i <= r; i++) {
for (int j = 1; j <= c; j++) {
for (int k = 0; k < 4; k++) {
if (find(a[i][j], i, j, dx[k], dy[k])) {
ans++;
}
}
}
}
cout << ans << endl;
fclose(stdin);
fclose(stdout);
return 0;
}
``````