- 浏览: 36739 次
- 性别:
- 来自: 杭州
最新评论
文章列表
Sample Input
3 2 3
1 2
1 3
1 2 3
Sample Output
1
0
0
#include <iostream>
#include <string.h>
using namespace std;
int map[1000][1000]={0};
int copy_map[1000][1000]={0};
bool visit[1000];
bool need_to_check[1000];
void dfs(int n,int N)
{
for(int i = 1; i & ...
PAT1003 Emergency
- 博客分类:
- PAT
Sample Input
5 6 0 2
1 2 1 5 3
0 1 1
0 2 2
0 3 1
1 2 1
2 4 1
3 4 1
Sample Output
2 4
#include <iostream>
using namespace std;
#define INF 1000000
int Graph[500][500];
int TeamNum[500]; // 每个城市拯救队伍数目
int s[500]; // 判断是否已存入该点到S集合中
int D ...
PAT1041 Be Unique
- 博客分类:
- PAT
找出只出现过一次的数,用各种排序必然超时,需要用数组做hash表
Sample Input 1:7 5 31 5 88 67 88 17Sample Output 1:31Sample Input 2:5 888 666 666 888 888Sample Output 2:None
#include <stdio.h>
#include <stdlib.h>
#define MAX 10000
#define MAX1 100000
int s[MAX] = {0},t[MAX1];
int main()
{
long in ...
PAT1042 Shuffling Machine
- 博客分类:
- PAT
扑克洗牌
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <algorithm>
using namespace std;
void Createpoker(vector<string> &poker, string s)
{
for (int i = 1; i < 14; i++)
{ ...
求最长回文子串
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
string a;
getline(cin,a);
int max = 0;
int length = a.size();
for(int i = 0; i < length; i++)
{
for(int j = 0; i - j >= 0 ...
PAT1036 Boys vs Girls
- 博客分类:
- PAT
Sample Input 1:
3
Joe M Math990112 89
Mike M CS991301 100
Mary F EE990830 95
Sample Output 1:
Mary EE990830
Joe Math990112
6
Sample Input 2:
1
Jean M AA980920 60
Sample Output 2:
Absent
Jean AA980920
NA
#include <iostream>
#include <iomanip> ...
PAT1035 Password
- 博客分类:
- PAT
Sample Input 1:
3
Team000002 Rlsp0dfa
Team000003 perfectpwd
Team000001 R1spOdfa
Sample Output 1:
2
Team000002 RLsp%dfa
Team000001 R@spodfa
Sample Input 2:
1
team110 abcdefg332
Sample Output 2:
There is 1 account and no account is modified
Sample Input 3:
2
team110 abcdefg22 ...
PAT1031 Hello World for U
- 博客分类:
- PAT
Sample Input:
helloworld!
Sample Output:
h !
e d
l l
lowor
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
string str;
cin>>str;
int length = str.length();
int n1 = len ...
PAT1029 Median
- 博客分类:
- PAT
用标准库的排序全部超时,需要自己实现,另外还不能用cin cout
Sample Input
4 11 12 13 14
5 9 10 15 16 17
Sample Output
13
#include <stdio.h>
int N1[1000000];
int N2[1000000];
int M[2000000];
int main()
{
int lenN1;
scanf("%d",&lenN1);
for (int i = 0; ...
PAT1028 List Sorting
- 博客分类:
- PAT
用vector最后一个用例超时了。。。
Sample Input 1
3 1
000007 James 85
000010 Amy 90
000001 Zoe 60
Sample Output 1
000001 Zoe 60
000007 James 85
000010 Amy 90
Sample Input 2
4 2
000007 James 85
000010 Amy 90
000001 Zoe 60
000002 James 98
Sample Output 2
000010 Amy 90
000002 James 9 ...
Sample Input
15 43 71
Sample Output
#123456
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void convert(int a)
{
int c=a/13,r=a%13;
if(c==0)
{
if (r < 10)
{
printf(&q ...
PAT1025 PAT Ranking
- 博客分类:
- PAT
Sample Input:
2
5
1234567890001 95
1234567890005 100
1234567890003 95
1234567890002 77
1234567890004 85
4
1234567890013 65
1234567890011 25
1234567890014 100
1234567890012 85
Sample Output:
9
1234567890005 1 1 1
1234567890014 1 2 1
1234567890001 3 1 2
1234567890003 3 1 2
1234567 ...
大数的相加
比较两个字符串中字符完全相同
Sample Input:
1234567899
Sample Output:
Yes
2469135798
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;
string doubleadd(string s)
{
int delta ...
PAT1020 Tree Traversals
- 博客分类:
- PAT
已知中序遍历 后序遍历,求层次遍历
Sample Input:
7
2 3 1 5 7 6 4
1 2 3 4 5 6 7
Sample Output:
4 1 6 3 5 7 2
#include <string.h>
#include <iostream>
using namespace std;
#define MAX_TREE_SIZE 30
typedef struct BiTNode
{
int data;
struct BiTNode *lchild,*rchild;
}B ...