UNICORN Programming Contest 2022(AtCoder Beginner Contest 269)
思路:
就输出(a+b)*(c-d)即可
#include
using namespace std;
#define int long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define SZ(v) ((int)v.size())
#define fs first
#define sc second
const int N=2e6+10,M=2e5;
typedef double db;
typedef pairpii;
int n,m,k,Q,cnt,t;
vectordel;
//int a[200010],b[200010];
int prime[N];
bool st[N];
mapmp;
void solve(){
int a,b,c,d;cin>>a>>b>>c>>d;
cout<<(a+b)*(c-d)<>t;
t=1;
while(t--)solve();
}
思路:
记录行和列的开始结束位置即可
#include
using namespace std;
#define int long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define SZ(v) ((int)v.size())
#define fs first
#define sc second
const int N=2e6+10,M=2e5;
typedef double db;
typedef pairpii;
int n,m,k,Q,cnt,t;
vectordel;
//int a[200010],b[200010];
int prime[N];
bool st[N];
mapmp;
char g[11][11];
void solve(){
for(int i=1;i<=10;i++){
for(int j=1;j<=10;j++){
cin>>g[i][j];
}
}
int x1=0,y1=0,x2=0,y2=0;
//cin>>x1>>y1>>x2>>y2;
for(int i=1;i<=10;i++){
for(int j=1;j<=10;j++){
if(g[i][j]=='#'&&x1==0&&x2==0){
x1=i,x2=j;
}
if(g[i][j]=='#'){
y1=i,y2=j;
}
}
}
cout<>t;
t=1;
while(t--)solve();
}
思路:
找某一位如果是1那么这位先输出0在输出1在转换为10进制,即是求每位所以可能,但是某位为0该位只能是0
#include
using namespace std;
#define int long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define SZ(v) ((int)v.size())
#define fs first
#define sc second
const int N=2e6+10,M=2e5;
typedef double db;
typedef pairpii;
int n,m,k,Q,cnt,t;
vectordel;
//int a[200010],b[200010];
int prime[N];
bool st[N];
mapmp;
char g[11][11];
void solve(){
int n;cin>>n;
string s;
int m=n;
vectora={0};
for(int i=n;i;i=(i-1)&m){
a.push_back(i);
}
sort(a.begin(),a.end());
for(auto x:a) cout<>t;
t=1;
while(t--)solve();
}
思路:
bfs搜索一遍,类似于找到岛屿数量,模拟以下能走的位置即可
(i−1,j−1)
(i−1,j)
(i,j−1)
(i,j+1)
(i+1,j)
(i+1,j+1)
#include
using namespace std;
#define int long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define SZ(v) ((int)v.size())
#define x first
#define y second
const int N=2e6+10,M=2e5;
typedef double db;
typedef pairpii;
int n,m,k,Q,cnt,t;
vectordel;
//int a[200010],b[200010];
int prime[N];
mapmp;
char g[11][11];
int a[2100][2100];
bool st[2100][2100];
void bfs(int x,int y){
queueq;
q.push({x,y});
st[x][y]=1;
while(q.size()){
auto t=q.front();q.pop();
if(t.x-1>=1&&t.y-1>=1&&!st[t.x-1][t.y-1]&&a[t.x-1][t.y-1]){
q.push({t.x-1,t.y-1});
st[t.x-1][t.y-1]=1;
}
if(t.x-1>=1&&!st[t.x-1][t.y]&&a[t.x-1][t.y]){
q.push({t.x-1,t.y});
st[t.x-1][t.y]=1;
}
if(t.y-1>=1&&!st[t.x][t.y-1]&&a[t.x][t.y-1]){
q.push({t.x,t.y-1});
st[t.x][t.y-1]=1;
}
if(t.x+1<=2001&&!st[t.x+1][t.y]&&a[t.x+1][t.y]){
q.push({t.x+1,t.y});
st[t.x+1][t.y]=1;
}
if(t.y+1<=2001&&!st[t.x][t.y+1]&&a[t.x][t.y+1]){
q.push({t.x,t.y+1});
st[t.x][t.y+1]=1;
}
if(t.x+1<=2001&&t.y+1<=2001&&!st[t.x+1][t.y+1]&&a[t.x+1][t.y+1]){
q.push({t.x+1,t.y+1});
st[t.x+1][t.y+1]=1;
}
}
}
void solve(){
int n;cin>>n;
for(int i=1;i<=n;i++){
int x,y;
cin>>x>>y;
a[x+1001][y+1001]=1;
}
int res=0;
for(int i=1;i<=2001;i++){
for(int j=1;j<=2001;j++){
if(a[i][j]==1&&!st[i][j]){
res++;
bfs(i,j);
}
}
}
cout<>t;
t=1;
while(t--)solve();
}