#include<cstdio> #include <iostream> #include<string> #include<algorithm> #include <set> using namespace std; #define REP(x, n) for(int x = 0; x < n; x++) #define PB push_back #define LL long long #define MAX 1000005 #define FORD(x,b,e) for(int x = b; x >= e; x--) // bool wayToSort(int i, int j) { return i > j; } int main() { int n; int a[MAX]; scanf("%d", &n); REP(x, n){ scanf("%d", &(a[x])); } /*sort(a, a + n, wayToSort); REP(x, n){ printf("%d\n", a[x]); } printf("\n"); int * ones_it = std::find(a, a+n, 1); int ones = ones_it - a; // index pierwszej jedynki */// printf("%d\n", ones); //int one_count = n - ones; //ile jedynek // printf("%d %d\n", ones, one_count); int one_count = std::count (a, a+n, 1); // printf("%d\n", one_count); if (one_count >= 2){ printf("%d\n", 0); printf("%d\n", 2); printf("%d %d\n", 1, 2); } else{ if (one_count == 1){ printf("%d\n", 1); printf("%d\n", 2); printf("%d %d\n", 1, 2); } else{ printf("%d\n", 2); printf("%d\n", 2); printf("%d %d\n", 1, 2); } } // int arr_sum[MAX] = {}; /* int arr_ref[MAX] = {}; // printf("%d\n", arr_ref[4]); std::set<int>::iterator it; std::set<int> myset; if (a[0]<=one_count){ myset.insert(a[0]); arr_ref[a[0]]=0; } for(int x = 1; x < ones; x++){ std::set<int> tempset; if (a[x]<=one_count){ tempset.insert(a[x]); arr_ref[a[x]] = 0; } // if (a[x]==2) // break; for (it=myset.begin(); it!=myset.end(); ++it){ // std::cout << ' ' << *it; if (*it + a[x] - 2 <= one_count){ tempset.insert(*it + a[x] - 2); arr_ref[*it + a[x] - 2]= a[x] - 2; } } myset.insert(tempset.begin(), tempset.end()); printf("\n", a[x]); for (it=myset.begin(); it!=myset.end(); ++it){ printf("%d ", *it); } printf("\n", *it); } */ /* LL wynik = 0; string word; // std::getline(std::cin, word); cin>>word; // scanf("%s", &word); // cout<<word<<endl; int ln = word.length(); // cout<<ln<<endl; int start = 0; for(int x = 2; x < ln; x++){ if (is_zero(word[x-2]) == is_zero(word[x-1]) && is_zero(word[x-1])== is_zero(word[x])){ // cout<<word[x-2]<<word[x]<<word[x]<<endl; wynik += (x-start-1) * (ln - x); // cout<<x<< " "<<x-start-1<<" "<<ln-x<< " "<< wynik <<" " << x - 1<<endl; start = x - 1; } } cout<<wynik<<endl; */ return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | #include<cstdio> #include <iostream> #include<string> #include<algorithm> #include <set> using namespace std; #define REP(x, n) for(int x = 0; x < n; x++) #define PB push_back #define LL long long #define MAX 1000005 #define FORD(x,b,e) for(int x = b; x >= e; x--) // bool wayToSort(int i, int j) { return i > j; } int main() { int n; int a[MAX]; scanf("%d", &n); REP(x, n){ scanf("%d", &(a[x])); } /*sort(a, a + n, wayToSort); REP(x, n){ printf("%d\n", a[x]); } printf("\n"); int * ones_it = std::find(a, a+n, 1); int ones = ones_it - a; // index pierwszej jedynki */// printf("%d\n", ones); //int one_count = n - ones; //ile jedynek // printf("%d %d\n", ones, one_count); int one_count = std::count (a, a+n, 1); // printf("%d\n", one_count); if (one_count >= 2){ printf("%d\n", 0); printf("%d\n", 2); printf("%d %d\n", 1, 2); } else{ if (one_count == 1){ printf("%d\n", 1); printf("%d\n", 2); printf("%d %d\n", 1, 2); } else{ printf("%d\n", 2); printf("%d\n", 2); printf("%d %d\n", 1, 2); } } // int arr_sum[MAX] = {}; /* int arr_ref[MAX] = {}; // printf("%d\n", arr_ref[4]); std::set<int>::iterator it; std::set<int> myset; if (a[0]<=one_count){ myset.insert(a[0]); arr_ref[a[0]]=0; } for(int x = 1; x < ones; x++){ std::set<int> tempset; if (a[x]<=one_count){ tempset.insert(a[x]); arr_ref[a[x]] = 0; } // if (a[x]==2) // break; for (it=myset.begin(); it!=myset.end(); ++it){ // std::cout << ' ' << *it; if (*it + a[x] - 2 <= one_count){ tempset.insert(*it + a[x] - 2); arr_ref[*it + a[x] - 2]= a[x] - 2; } } myset.insert(tempset.begin(), tempset.end()); printf("\n", a[x]); for (it=myset.begin(); it!=myset.end(); ++it){ printf("%d ", *it); } printf("\n", *it); } */ /* LL wynik = 0; string word; // std::getline(std::cin, word); cin>>word; // scanf("%s", &word); // cout<<word<<endl; int ln = word.length(); // cout<<ln<<endl; int start = 0; for(int x = 2; x < ln; x++){ if (is_zero(word[x-2]) == is_zero(word[x-1]) && is_zero(word[x-1])== is_zero(word[x])){ // cout<<word[x-2]<<word[x]<<word[x]<<endl; wynik += (x-start-1) * (ln - x); // cout<<x<< " "<<x-start-1<<" "<<ln-x<< " "<< wynik <<" " << x - 1<<endl; start = x - 1; } } cout<<wynik<<endl; */ return 0; } |