1 条题解

  • 0
    @ 2025-8-24 23:08:13

    自动搬运

    查看原文

    来自洛谷,原作者为

    avatar AFO_Lzx
    Inter Milano is the greatest football club in the world! || 终于有钩子了 || AFOed

    搬运于2025-08-24 23:08:13,当前版本为作者最后更新于2025-01-09 20:48:53,作者可能在搬运后再次修改,您可在原文处查看最新版

    自动搬运只会搬运当前题目点赞数最高的题解,您可前往洛谷题解查看更多

    以下是正文


    题目传送门

    Solution\texttt{Solution}

    一道水题,按照题意模拟即可。注意在每一次的移动之后,有两项操作:

    • axa_x 的值要对应变为移动后的位置。
    • 标记数组要把原来的位置改为 00,移动后的位置改为 11

    还有,error! 后面有感叹号,一定不要漏掉,否则你会喜提 00 分大礼包一份。

    Code\texttt{Code}

    #include<bits/stdc++.h>
    #define int long long
    using namespace std;
    
    const int maxn = 1e3 + 5;
    int n, m, k, a[maxn];
    bool vis[maxn];
    
    signed main() {
    	ios::sync_with_stdio(0);
    	cin.tie(0), cout.tie(0);
    	
    	cin >> n >> m >> k;
    	
    	for (int i = 1; i <= m; i++) {
    		cin >> a[i];
    		vis[a[i]] = true;
    	}
    	
    	while (k--) {
    		int x; cin >> x;
    		int num = a[x];
    		bool flag = false;
    		
    		for (int i = 1; i <= n - num; i++) {
    			if (vis[num + i] == false) {
    				a[x] += i;
    				cout << a[x] << "\n";
    				vis[num] = false;
    				vis[num + i] = true;
    				flag = true;
    				break;
    			}
    		}
    		
    		if (!flag) cout << "error!\n";
    	}
    	
    	return 0;
    }
    

    完结,这题真简单。

    • 1

    信息

    ID
    11268
    时间
    1000ms
    内存
    512MiB
    难度
    2
    标签
    递交数
    0
    已通过
    0
    上传者