Coderforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)
2016-10-09 07:35
399 查看
A
#include<iostream>
using namespace std;
string s[7]={"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
int main()
{
string s1,s2;
cin>>s1>>s2;
if(s1==s2) printf("YES\n");
else{
int i;
for(i=0;i<7;i++) if(s[i]==s1) break;
if(s2==s[(i+2)%7]||s2==s[(i+3)%7]) printf("YES\n");
else printf("NO\n");
}
return 0;
}
B
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
int p[30][30];
int n,m;
bool check()
{
rep(i,0,n){
int cnt=0;
rep(j,0,m) cnt+=(p[i][j]!=j+1);
if(cnt>2) return 0;
}
return 1;
}
int main()
{
cin>>n>>m;
rep(i,0,n) rep(j,0,m) cin>>p[i][j];
rep(a,0,m) rep(b,a,m) {
rep(i,0,n) swap(p[i][a],p[i][b]);
if(check()){
cout<<"YES"<<endl;
return 0;
}
rep(i,0,n) swap(p[i][a],p[i][b]);
}
cout<<"NO"<<endl;
}
#include<iostream>
using namespace std;
string s[7]={"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
int main()
{
string s1,s2;
cin>>s1>>s2;
if(s1==s2) printf("YES\n");
else{
int i;
for(i=0;i<7;i++) if(s[i]==s1) break;
if(s2==s[(i+2)%7]||s2==s[(i+3)%7]) printf("YES\n");
else printf("NO\n");
}
return 0;
}
B
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
int p[30][30];
int n,m;
bool check()
{
rep(i,0,n){
int cnt=0;
rep(j,0,m) cnt+=(p[i][j]!=j+1);
if(cnt>2) return 0;
}
return 1;
}
int main()
{
cin>>n>>m;
rep(i,0,n) rep(j,0,m) cin>>p[i][j];
rep(a,0,m) rep(b,a,m) {
rep(i,0,n) swap(p[i][a],p[i][b]);
if(check()){
cout<<"YES"<<endl;
return 0;
}
rep(i,0,n) swap(p[i][a],p[i][b]);
}
cout<<"NO"<<endl;
}
相关文章推荐
- Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)
- codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) 题解(A-D)
- codeforces Intel Code Challenge Final Round (div.1 + div.2 combined)
- Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C. Ray Tracing
- 【Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) E】 【动态规划+网络流的思想】 Goods transportation
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) E. Goods transportation (非官方贪心解法)
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A题
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)A. Checking the Calendar
- Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort(暴力)
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C. Ray Tracing 数学
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C. Ray Tracing
- Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar(水题)
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)
- Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar(水题)
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) -- C. Ray Tracing(STL乱搞)
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)题解报告
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) E. Goods transportation 动态规划