ARC139 C. One Three Nine
Difficulty:2406
問題
解法
実装
code:cpp
bool solve(){
LL(n,m);
bool swaped = n>m;
if(n>m)swap(n,m);
ll i{1},j{1};
vector<pair<ll,ll>>ans;
while(1){
ll r{2};
if(i==1)r++;
rep(jj,r){
rep(ii,3){
if(i<=n&&j<=m&&j>0)ans.push_back({i,j});
j++;
}
j-=3;
i++;
}
i--;
if(i>n)i=n;
j+=3;
if(i==n){
for(;j<=m;j++){
if(i<=n&&j<=m&&j>0)ans.push_back({i,j});
}
break;
}
else{
rep(ii,2){
if(i<=n&&j<=m&&j>0)ans.push_back({i,j});
j++;
}
j-=3;
i++;
}
}
O(ans.size());
if(swaped)O(r,l);
else O(l,r);
}
return false;
}