这场总体感觉不是很难,但是题目理解上有些费劲
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
int n;
cin>>n;
int mid=n/2;
int before=n*n/2,behind=before+1;
for(int i=1;i<=n;i++)
{
for(int j=0;j<mid;j++)
cout<<before--<<" ";
for(int j=0;j<mid;j++)
cout<<behind++<<" ";
cout<<endl;
}
return 0;
}
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
using namespace std;
int main()
{
//freopen("in.txt","r",stdin);
int x,y;
set<int> cntx,cnty;
map<pair<int,int>,bool> m;
for(int i=0;i<8;i++)
{
cin>>x>>y;
cntx.insert(x);
cnty.insert(y);
m[make_pair(x,y)]=true;
}
if(cntx.size()!=3||cnty.size()!=3||m.size()!=8)cout<<"ugly"<<endl;
else
{
set<int>::iterator it1=cntx.begin(),it2=cnty.begin();
it1++,it2++;
if(m[make_pair(*it1,*it2)])cout<<"ugly";
else cout<<"respectable";
cout<<endl;
}
return 0;
}
C - Secrets
题意看了半天没看懂
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long LL;
int main()
{
LL n;
cin>>n;
while(!(n%3))n/=3;
cout<<(n/3)+1<<endl;
return 0;
}
D - Chips
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1010;
int n,m,visx[maxn],visy[maxn];
int solve(int *vis)
{
int ans=0;
for(int i=2;i<=n-1;i++)
if(!vis[i])ans++;
return ans;
}
int main()
{
//freopen("in.txt","r",stdin);
cin>>n>>m;
int x,y;
memset(visx,0,sizeof(visx));
memset(visy,0,sizeof(visy));
for(int i=0;i<m;i++)
{
cin>>x>>y;
visy[y]++;
visx[x]++;
}
int ans=0;
ans+=solve(visx)+solve(visy);
if((n&1)&&!visx[n/2+1]&&!visy[n/2+1])ans--;
cout<<ans<<endl;
return 0;
}