比赛链接: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. keep your work after network broken

    如下设置可以保证在网络中断后tso仍然可以继续active,并等到下一次reconnect sys1.tcpparms(tnprof7d) -- Dataset name and PDS name b ...

  2. Swift常量和变量

    常量和变量由一个特定名称来表示,如maxNumber 或者 message.常量所指向的是一个特定类型的值, 如数字10或者字符”hello”.变量的值可以根据需要不断修改,而常量的值是不能够被二次修 ...

  3. 使用node-webkit开发exe窗口程序

    首发:个人博客,更新&纠错&回复 ====关于原生程序与壳中程序的议论begin==== 在所有用户windows机器上都能直接跑的程序,如果不采用微软系的语言,如VB,C++,C#等 ...

  4. poj2407 Relatives 欧拉函数基本应用

    题意很简单 就是欧拉函数的定义: 欧拉函数是指:对于一个正整数n,小于n且和n互质的正整数(包括1)的个数,记作φ(n) .题目求的就是φ(n) 根据 通式:φ(x)=x*(1-1/p1)*(1-1/ ...

  5. java的web项目中使用cookie保存用户登陆信息

    本文转自:http://lever0066.iteye.com/blog/1735963 最近在编写论坛系统的实现,其中就涉及到用户登陆后保持会话直到浏览器关闭,同时可以使用cookie保存登陆信息以 ...

  6. 161108、Java IO流读写文件的几个注意点

    平时写IO相关代码机会挺少的,但却都知道使用BufferedXXXX来读写效率高,没想到里面还有这么多陷阱,这两天突然被其中一个陷阱折腾一下:读一个文件,然后写到另外一个文件,前后两个文件居然不一样? ...

  7. zabbix agent 类型自带的key

    zabbix服务器端通过与zabbix agent通信来获取客户端服务器的数据,agent分为两个版本,在配置主机我们可以看到一个是agent,另一个是agent(active). agent:zab ...

  8. WKWebView新特性及JS交互

    引言 一直听说WKWebView比UIWebView强大许多,可是一直没有使用到,今天花了点时间看写了个例子,对其API的使用有所了解,为了日后能少走弯路,也为了让大家更容易学习上手,这里写下这篇文章 ...

  9. CGRectGet系列

    CGRectGetHeight返回label本身的高度 CGRectGetMinY返回label顶部的坐标 CGRectGetMaxY 返回label底部的坐标 CGRectGetMinX 返回lab ...

  10. jquery easyui读取json文件乱码

    输出的json要求用utf-8,否则因json的编码格式有问题显示不了中文.记事本默认编码是ANSI,若保存的json是由记事本改后的缀名,则json格式有问题,显示中文为乱码. 解决方法:打开.js ...