首页 > 其他 > 详细

101 Hack October'14

时间:2014-11-16 21:28:01      阅读:346      评论:0      收藏:0      [点我收藏+]

拖了近一个月的总结。(可能源于最近不太想做事:()

A题

给出n个长度都为n的字符串,你只可以对每个字符串分别排序,问当每个字符串按升序排序之后,每一列是否也是升序的。

 1 #include <cmath>
 2 #include <cstdio>
 3 #include <vector>
 4 #include <iostream>
 5 #include <algorithm>
 6 using namespace std;
 7 
 8
 9 int main() {
10     ios::sync_with_stdio(false);
11     int t;
12     cin >> t;
13     while (t--) {
14         int n;
15         cin >> n;
16         string ch1, ch2;
17         cin >> ch1;
18         sort(ch1.begin(), ch1.end());
19         bool flag = true;
20         for (int i = 1; i < n; i++) {
21             cin >> ch2;
22             sort(ch2.begin(), ch2.end());
23             for (int j = 0; j < n; j++) if (ch1[j] > ch2[j]) flag = false;
24             //if (ch1 > ch2) flag = false;
25             swap(ch1, ch2);
26         }
27         if (flag) cout << "YES\n";
28         else cout << "NO\n";
29     }
30     
31     return 0;
32 }

B题

C题

D题

E题

目前是没有能力做这个题了。

101 Hack October'14

原文:http://www.cnblogs.com/Stomach-ache/p/4101856.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!