Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)

A. Checking the Calendar

题意:给出两个周几, 问是否有这样一个non-leap year, 在一年中 某一个月的第一天等于第一个给出的周几, 这个月的下一个月的第一天等于第二个给出的周几、

我又他喵的少读题了、 以后这两个周几可以互换判断... 结果可想而知

#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<queue>
#include<stack>
#include<utility>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
const int qq = 1e5+10;
int month[20]={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string c[10]={"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
int main(){
	string x,y;
	cin >> x >> y;
	int a,b;
	for(int i=0; i<7; ++i)
		if(x==c[i])	a = i;
	for(int i=0; i<7; ++i)
		if(y==c[i])	b = i;
	int flag = 0;
//	for(int i=1; i<=11; ++i)
//		if(a==(b+month[i])%7)	flag = 1;
	for(int i=1; i<=11; ++i)
		if(b==(a+month[i])%7)	flag = 1;
	if(flag)	printf("YES\n");
	else	printf("NO\n");
	return 0;
} 

B. Batch Sort

题意:给出一个n*m的矩阵, 你在每一行可以交换两个元素,每行只能这样操作一次, 然后还有一次直接交换两列的操作,  问是否通过这0~n+1次操作能否是的每一行都是升序的序列, (每行给出的元素都是1 to m)

思路:先判断只交换行是否能满足条件,不满足的话枚举所有交换列的结果,再看能否通过交换行能满足

我..... 再循环里判断p>n     居然写成了p>=n... 

#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<queue>
#include<stack>
#include<utility>
#include<string>
using namespace std;
typedef long long ll;
const int qq = 200;
int n,m;
int dp[qq][qq];
int row[qq], col[qq];
int main(){
	scanf("%d%d", &n, &m);
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)	scanf("%d", &dp[i][j]);
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
			if(j!=dp[i][j])
				row[i]++;
	int flag = 1;
	for(int i=1; i<=n; ++i)
		if(row[i]==2||row[i]==0)	continue;
		else	flag = 0;
	if(flag){
		printf("YES\n");
		return 0;
	}
	for(int i=1; i<=m; ++i){
		for(int j=i+1; j<=m; ++j){
			memset(row, 0, sizeof(row));
			for(int k=1; k<=n; ++k)
				swap(dp[k][i], dp[k][j]);
			for(int q=1; q<=n; ++q)
				for(int w=1; w<=m; ++w)
					if(w!=dp[q][w])	row[q]++;
			int p;
			for(p=1; p<=n; ++p){
				if(row[p]==2||row[p]==0)	continue;
				break;
			}
			if(p>n)	flag = 1;
			for(int k=1; k<=n; ++k)
				swap(dp[k][i], dp[k][j]);
		}
	}
	if(flag)	printf("YES\n");
	else	printf("NO\n");
	return 0;
}

两道超级水的题... 细节方面一定得加强阿

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值