比赛链接:http://codeforces.com/gym/100861

A模拟,注意两个特殊的缩写。

 #include <bits/stdc++.h>
using namespace std; typedef pair<string, string> pss;
const string MSU = "MSU";
const string SCH = "SCH";
const int maxn = ;
map<string, int> school;
int n;
string a, b;
vector<pss> team;
vector<pss> ret; string up(string x) {
int len = x.length();
for(int i = ; i < len; i++) {
if(x[i] >= 'a' && x[i] <= 'z') x[i] = x[i] - 'a' + 'A';
}
return x;
} int main() {
//freopen("in", "r", stdin);
while(~scanf("%d", &n)) {
school.clear(); team.clear(); ret.clear();
for(int i = ; i <= n; i++) {
cin >> a >> b;
team.push_back(pss(a, b));
}
for(int i = ; i < n; i++) {
string tmp = up(team[i].first);
if(team[i].first == SCH) continue;
if(school.find(tmp) == school.end()) {
ret.push_back(team[i]);
school[tmp] = ;
continue;
}
if(team[i].first == MSU) {
if(school[tmp] < ) {
ret.push_back(team[i]);
school[tmp]++;
}
}
else {
if(school[tmp] < ) {
ret.push_back(team[i]);
school[tmp]++;
}
}
}
if(ret.size() <= ) {
printf("%d\n", ret.size());
for(int i = ; i < ret.size(); i++) {
cout << ret[i].first <<" " << ret[i].second << endl;
}
}
else {
printf("%d\n", );
for(int i = ; i < ; i++) {
cout << ret[i].first <<" " << ret[i].second << endl;
}
}
}
return ;
}

B排序+离散化

 #include <bits/stdc++.h>
using namespace std; typedef long long LL;
typedef struct F {
int idx;
LL val;
}F;
typedef struct S {
int idx;
int val;
}S;
const int maxn = ;
const int maxm = ;
S s[maxm];
int k;
int n, m;
LL a, b, c;
F f[maxm];
LL ret[maxm]; int h[maxm], hcnt;
int t[maxm], tcnt; bool cmp1(S a, S b) {
if(a.val == b.val) return a.idx < b.idx;
return a.val > b.val;
} bool cmp2(F a, F b) {
if(a.val == b.val) return a.idx < b.idx;
return a.val > b.val;
} int id(int x) {
return lower_bound(h, h+hcnt, x) - h + ;
} int main() {
freopen("in", "r", stdin);
int x;
while(~scanf("%I64d%I64d%I64d%I64d",&f[].val,&a,&b,&c)) {
memset(ret, , sizeof(ret));
k = ; hcnt = , tcnt = ;
for(int i = ; i < maxm; i++) {
s[i].idx = -;
s[i].val = ;
}
scanf("%d%d",&n,&m);
for(int i = ; i <= n; i++) {
for(int j = ; j <= m; j++) {
scanf("%d", &x);
t[tcnt++] = x;
h[hcnt++] = x;
}
}
sort(h, h+hcnt); hcnt = unique(h, h+hcnt) - h;
for(int i = ; i < tcnt; i++) {
if(s[id(t[i])].idx == -) {
k++;
s[id(t[i])].idx = t[i];
}
s[id(t[i])].val++;
}
sort(s+, s+maxm, cmp1);
f[].idx = ;
for(int i = ; i <= k; i++) {
f[i].idx = i;
f[i].val = ((a * f[i-].val + b) % c) + ;
}
sort(f+, f+k+, cmp2);
for(int i = ; i<= k; i++) {
ret[f[i].idx] = s[i].idx;
}
printf("%d\n", k);
for(int i = ; i<= k; i++) {
printf("%I64d%c", ret[i], i == k ? '\n' : ' ');
}
}
return ;
}

C贪心,就像搭积木一样,全是1*1*1的小方块,要想让表面积尽可能小,那就把他们往一个角落堆。比如

3 3

1 2 3 4 5 6 7 8 9这样的数据,那么排出来就是。

9 8 5

7 6 4

3 2 1

这样可以保证遮盖的部分最大。那么只需要找到第一行和第一列的高度,两边加起来乘2就行了。

 #include <bits/stdc++.h>
using namespace std; const int maxn = ;
int n, m, k;
int t[maxn*maxn]; int main() {
// freopen("in", "r", stdin);
while(~scanf("%d%d",&m,&n)) {
k = ;
if(m < n) swap(m, n);
for(int i = ; i <= m; i++) {
for(int j = ; j <= n; j++) {
scanf("%d",&t[k++]);
}
}
sort(t, t+k, greater<int>());
int ret = ;
for(int i = ; i < n; i++) {
ret += t[i*i];
ret += t[i*(i+)];
}
for(int i = n; i < m; i++) {
ret += t[i*n];
}
cout << ret * << endl;
}
return ;
}

G首先知道结果为0的情况,那就是小于等于3个点的时候;想要结果为1,那么必然是两两配对出来的新点位置重合。否则可以让任意四个点组成一个四边形,这个时候分别取每边的中点,构成的四边形一定是平行四边形(很好证明)。所以第二次就一定会有交点了(对角线中心)。

 #include <bits/stdc++.h>
using namespace std; typedef pair<int,int> pii;
const int maxn = ;
int n;
int x[maxn], y[maxn];
map<pii, bool> s; int main() {
// freopen("in", "r", stdin);
while(~scanf("%d", &n)) {
s.clear();
for(int i = ; i <= n; i++) {
scanf("%d%d",&x[i],&y[i]);
x[i] <<= ; y[i] <<= ;
}
if(n <= ) {
puts("");
continue;
}
bool flag = ;
for(int i = ; i <= n; i++) {
if(flag) break;
for(int j = i+; j <= n; j++) {
int tx = (x[i] + x[j]) / ;
int ty = (y[i] + y[j]) / ;
if(s.find(pii(tx, ty)) != s.end()) {
printf("1\n");
flag = ;
break;
}
s[pii(tx, ty)] = ;
}
}
if(!flag) puts("");
}
return ;
}

L打表找规律,然后就很简单了。

 #include <bits/stdc++.h>
using namespace std; const int maxn = ;
bool vis[maxn]; bool lucky(int s) {
int x, y;
x = s % ;
s /= ;
y = s;
int sx = , sy = ;
while(x) {
sx += x % ;
x /= ;
}
while(y) {
sy += y % ;
y /= ;
}
return sx == sy;
} int main() {
memset(vis, , sizeof(vis));
for(int i = ; i <= ; i++) {
vis[i] = lucky(i);
}
int ret = ;
int tmp = ;
int rl ,rh;
int lo;
lo = ;
for(int i = ; i <= ; i++) {
if(vis[i]) {
if(ret < tmp) {
rl = lo;
rh = i - ;
ret = tmp;
}
tmp = ;
lo = i + ;
}
else {
tmp++;
}
}
cout <<ret <<endl;
cout << rl << " " << rh << endl;
}
 #include <bits/stdc++.h>
using namespace std; string ret[][] = {
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
};
int main() {
int n;
while(~scanf("%d", &n)) {
cout << ret[n][] << endl << ret[n][] << endl;
}
}

[Gym]2008-2009 ACM-ICPC, NEERC, Moscow Subregional Contest的更多相关文章

  1. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 G. Garden Gathering

    Problem G. Garden Gathering Input file: standard input Output file: standard output Time limit: 3 se ...

  2. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 D. Delay Time

    Problem D. Delay Time Input file: standard input Output file: standard output Time limit: 1 second M ...

  3. 2018-2019 ICPC, NEERC, Southern Subregional Contest

    目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...

  4. Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest

    2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...

  5. 2016 NEERC, Moscow Subregional Contest K. Knights of the Old Republic(Kruskal思想)

    2016 NEERC, Moscow Subregional Contest K. Knights of the Old Republic 题意:有一张图,第i个点被占领需要ai个兵,而每个兵传送至该 ...

  6. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 K. King’s Rout

    K. King's Rout time limit per test 4 seconds memory limit per test 512 megabytes input standard inpu ...

  7. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 I. Illegal or Not?

    I. Illegal or Not? time limit per test 1 second memory limit per test 512 megabytes input standard i ...

  8. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 H. Hashing

    H. Hashing time limit per test 1 second memory limit per test 512 megabytes input standard input out ...

  9. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 C. Colder-Hotter

    C. Colder-Hotter time limit per test 1 second memory limit per test 512 megabytes input standard inp ...

随机推荐

  1. fedora环境安装webkit支持作爬虫下载解析JS

    环境: 我使用的fedora19.1-xfce版本,属于redhat系的桌面环境. 1.安装 webkit源码安装webkit失败,这里提供的是yum安装方式. a.查看当前yum库中的webkit资 ...

  2. stdout.read()与stdout.readlines()方法同时使用后果

    stdout.read()与stdout.readlines()方法同时使用将无法导致最后使用的stdout.readlines()读取的内容为空,原因是首先调用的stdout.read()已将数据读 ...

  3. C# 探索c#之Async、Await剖析

    探索c#之Async.Await剖析 作者:蘑菇先生 出处:http://mushroom.cnblogs.com/

  4. page指令

    <%@ page 属性1=“value” 属性2=“value2” ......%> page的属性有13种: 1)language  --- 声明所使用的脚本语言的种类.(可省略) va ...

  5. 完整学习git四git对象

    1查看git对象 git cat-file 实践 git head到底指向的是什么 ➜ gittest git:(master) find .git -name HEAD -o -name maste ...

  6. combobox中动态加入几个checkbox,实现下拉框多选

    combobox中动态加入几个checkbox,实现下拉框多选,将一个checkbox选中时其内容就会在combobox中显示出来,将另一个checkbox选中时其内容会跟在第一个checkbox的内 ...

  7. SlickGrid example 7:鼠标事件

    响应鼠标事件,可以左键快捷选择切换选项,可右键弹出菜单栏.   代码: <!DOCTYPE HTML> <html> <head> <meta http-eq ...

  8. c#省市联动

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  9. Present

    Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...

  10. Stars(树状数组或线段树)

    Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37323 Accepted: 16278 Description A ...