Submission #6461614


Source Code Expand

Copy
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N + 1];
  for(int i = 1; i <= N; i++) cin >> a[i];

  int cnt[N + 1];
  fill(cnt, cnt + N + 1, 0);
  vector<int> ans;

  for(int i = N; i >= 1; i--){
    //cout << "cnt" << i << " " << cnt[i] << endl;
    cnt[i] %= 2;
    if(cnt[i] != a[i]){
      ans.push_back(i);
      for(int j = 1; j * j <= i; j++){
        if(i % j == 0){
          if(j != i / j){
            cnt[j]++;
            cnt[i / j]++;
          } else {
            cnt[j]++;
          }
        }
      }
    }
  }

  cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); i++){
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}

Submission Info

Submission Time
Task D - Preparing Boxes
User syawacha
Language C++14 (GCC 5.4.1)
Score 400
Code Size 945 Byte
Status AC
Exec Time 189 ms
Memory 3064 KB

Judge Result

Set Name All Sample
Score / Max Score 400 / 400 0 / 0
Status
AC × 18
AC × 2
Set Name Test Cases
All sample_01, sample_02, testcase_0, testcase_1, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_2, testcase_3, testcase_4, testcase_5, testcase_6, testcase_7, testcase_8, testcase_9, testcase_add0
Sample sample_01, sample_02
Case Name Status Exec Time Memory
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB
testcase_0 AC 45 ms 1280 KB
testcase_1 AC 114 ms 2424 KB
testcase_10 AC 33 ms 1792 KB
testcase_11 AC 21 ms 1280 KB
testcase_12 AC 9 ms 512 KB
testcase_13 AC 1 ms 256 KB
testcase_14 AC 1 ms 256 KB
testcase_2 AC 28 ms 1024 KB
testcase_3 AC 58 ms 1532 KB
testcase_4 AC 64 ms 1660 KB
testcase_5 AC 174 ms 2936 KB
testcase_6 AC 90 ms 1912 KB
testcase_7 AC 189 ms 3064 KB
testcase_8 AC 33 ms 1792 KB
testcase_9 AC 5 ms 384 KB
testcase_add0 AC 156 ms 2936 KB