F- Desktop Rearrangement

F.-Desktop Rearrangement

题目

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

题意

给定初始图像,“*”代表图标,“."代表此位置没有东西,要让图标整齐的按列排放,最少需要移动多少个图标,给定坐标,若此位置上没有图标,则放置图标,若此位置上有图标,则将图标移除

思路

将二维坐标转变为一维坐标,然后模拟移动

代码

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n, m, t;
    cin >> n >> m >> t;
    char a[1005][1005], b[1005*1005];
    int ans = 0;
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            cin >> a[i][j];
            if (a[i][j] == '*') ans++;
            b[(j - 1) * n + i] = a[i][j];//转换为一维坐标
        }
    }
    int sum = 0;
    for (int i = ans + 1; i <= n * m; i++) if (b[i] == '*') sum++;//记录需要移动的次数
    while (t--) {
        ll x, y;
        cin >> x >> y;
        ll p = (y - 1) * n + x;//转换为一维坐标
        if (b[p] == '*') {//若一维坐标里存的是图标
            b[p] = '.';//则拿走图标
            if (p > ans) sum--;//如果拿走的图标在需要移动的次数里面,则少移动一次、
            if (p != ans && b[ans] == '*') sum++;//此位置已经是摆放好图标的位置,则多移动一次
            ans--;//图标减1
        } else {//此位置无图标
            b[p] = '*';//放入图标
            ans++;//图标增加
            if (p > ans) sum++;//放入的图标在需要移动的次数里面,则需要多移动一次
            if (p != ans && b[ans] == '*') sum--;//此位置是已经摆放好图标的位置,则少移动一次
        }
        cout << sum << endl;
    }
    return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
润色下面英文:The controlled drug delivery systems, due to their precise control of drug release in spatiotemporal level triggered by specific stimulating factors and advantages such as higher utilization ratio of drug, less side-effects to normal tissues and so forth, provide a new strategy for the precise treatment of many serious diseases, especially tumors. The materials that constitute the controlled drug delivery systems are called “smart materials” and they can respond to the stimuli of some internal (pH, redox, enzymes, etc.) or external (temperature, electrical/magnetic, ultrasonic and optical, etc.) environments. Before and after the response to the specific stimulus, the composition or conformational of smart materials will be changed, damaging the original balance of the delivery systems and releasing the drug from the delivery systems. Amongst them, the photo-controlled drug delivery systems, which display drug release controlled by light, demonstrated extensive potential applications, and received wide attention from researchers. In recent years, photo-controlled drug delivery systems based on different photo-responsive groups have been designed and developed for precise photo-controlled release of drugs. Herein, in this review, we introduced four photo-responsive groups including photocleavage groups, photoisomerization groups, photo-induced rearrangement groups and photocrosslinking groups, and their different photo-responsive mechanisms. Firstly, the photocleavage groups represented by O-nitrobenzyl are able to absorb the energy of the photons, inducing the cleavage of some specific covalent bonds. Secondly, azobenzenes, as a kind of photoisomerization groups, are able to convert reversibly between the apolar trans form and the polar cis form upon different light irradiation. Thirdly, 2-diazo-1,2-naphthoquinone as the representative of the photo-induced rearrangement groups will absorb specific photon energy, carrying out Wolff rearrangement reaction. Finally, coumarin is a promising category photocrosslinking groups that can undergo [2+2] cycloaddition reactions under light irradiation. The research progress of photo-controlled drug delivery systems based on different photo-responsive mechanisms were mainly reviewed. Additionally, the existing problems and the future research perspectives of photo-controlled drug delivery systems were proposed.
02-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值