幅優先探索 queue<int> q1, q2; q1.push(0); q2.push(1); while(!q1.empty()){ int a = q1.front(); int b = q2.front(); q1.pop(); q2.pop(); for(int i = 0; i < n; i++){ q1.push(2); q2.push(3); } }