比赛链接: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. php file_get_contents与curl性能比较

    1.fopen /file_get_contents 每次请求都会重新做DNS查询,并不对 DNS信息进行缓存.但是CURL会自动对DNS信息进行缓存.对同一域名下的网页或者图片的请求只需要一次DNS ...

  2. TI CC254x BLE教程 3

    通用属性配置(Generic Attribute Profiles) 1. 数据在services里面以特征字(characteristics)的形式展示出来 如你所见, 特征字包含属性(Proper ...

  3. Delphi内嵌汇编语言BASM精要(转帖)

    1 BASM概念简要  汇编语句由指令和零至三个表达式构成.表达式由常数(立即数).寄存器和标识符构成.例如: movsb        // 单指令语句 jmp @Here    // 一个表达式: ...

  4. PHP gmdate() 函数

    定义和用法 gmdate() 函数格式化 GMT/UTC 日期/时间. 同 date() 函数 类似,不同的是返回的时间是格林威治标准时(GMT). 语法 gmdate(format,timestam ...

  5. 查看mysql的状态

    实时查看mysql状态连接数 查询数 etc mysqladmin  -uroot  -p '' -h status -i 1

  6. http协议了解

    在web应用中,服务器把网页的HTML代码发送给浏览器,让浏览器显示出来,浏览器和服务器之间的传输协议就是HTTP协议.HTTP是在网络上传输HTML的协议,用于浏览器和服务器之间的通信. 一个网页打 ...

  7. 杭电1019-Least Common Multiple

    #include<stdio.h>int gcd(int a,int b);int main(){    int n,m,a,b,i,sum;//sum是最小公倍数    scanf(&q ...

  8. Linux下启动Oracle

    切换到oracle用户 su - oracle   启动监听 lsnrctl start   确认是不是想要启动的oracle实例 echo $ORACLE_SID   如果不是,切换SID  ora ...

  9. python-django 模型model字段类型说明

    V=models.CharField(max_length=None<, **options>) #varchar V=models.EmailField(<max_length=7 ...

  10. Doubles 分类: POJ 2015-06-12 18:24 11人阅读 评论(0) 收藏

    Doubles Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19954   Accepted: 11536 Descrip ...