#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = b[i];
    }
    
    for (int i = 0; i < m; i++) {
        int op, x, y;
        cin >> op >> x >> y;
        if (op == 1) {
            a[x-1] += a[y-1];
        } else if (op == 2) {
            a[x-1] *= a[y-1];
        }
    }
    
    for (int i = 0; i < n; i++) {
        cout << a[i] << " ";
    }
    
    return 0;
}
``
用C++讲解以下题目:题目描述jockbutt 有一个正整数序列长度为 �n分别为 �1�2��a 1 a 2 a n 她非常喜欢这个序列平时都非常爱惜它们。可是有一天当 jockbutt 在和你约会的时候有一只淘气的小猴子改变了这个序列。猴子操作了 �m 次。猴子的操作有两种类型:1 x y1 x y 表示第 �x 个元素加上第 �y 个元素。2 x y2 x y 表示第 �x 个元素乘上

原文地址: https://www.cveoy.top/t/topic/h0wH 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录