#include <iostream> using namespace std; int main(){ int n, k; cin >> n >> k; int *kolory1 = new int [n]; int *kolory2 = new int [n]; int *pomalowane1 = new int [n]; int *pomalowane2 = new int [n]; for(int i = 0; i < n; i++){ cin >> kolory1[i]; pomalowane1[i] = -1; } for(int i = 0; i < n; i++){ cin >> kolory2[i]; pomalowane2[i] = -1; } int *ciekawosc = new int [k]; for(int i = 0; i < k; i++){ ciekawosc[i] = 0; } int ciekawosc_tym = 0; for(int i = 0; i < 2*n; i++){ ciekawosc_tym = 0; for(int j = i; j < 2*n;j++){ int l = 0; while(kolory1[l] != j + 1 and kolory2[l] != j + 1){ l++; } int tab_tym[5]; // otoczenie 0 lewa, 1 lewa skos, 2 dół/góra, 3 prawa skos, 4 prawy if(kolory1[l] == j + 1){ pomalowane1[l] = i; if(l == 0){ tab_tym[0] = pomalowane1[n-1]; tab_tym[1] = pomalowane2[n-1]; } else{ tab_tym[0] = pomalowane1[l-1]; tab_tym[1] = pomalowane2[l-1]; } tab_tym[2] = pomalowane2[l]; if(l == n-1){ tab_tym[3] = pomalowane2[0]; tab_tym[4] = pomalowane1[0]; } else{ tab_tym[3] = pomalowane2[l+1]; tab_tym[4] = pomalowane1[l+1]; } } if(kolory2[l] == j + 1){ pomalowane2[l] = i; if(l == 0){ tab_tym[0] = pomalowane2[n-1]; tab_tym[1] = pomalowane1[n-1]; } else{ tab_tym[0] = pomalowane2[l-1]; tab_tym[1] = pomalowane1[l-1]; } tab_tym[2] = pomalowane1[l]; if(l == n-1){ tab_tym[3] = pomalowane1[0]; tab_tym[4] = pomalowane2[0]; } else{ tab_tym[3] = pomalowane1[l+1]; tab_tym[4] = pomalowane2[l+1]; } } ciekawosc_tym++; if(tab_tym[2] == i){ ciekawosc_tym--; } if(tab_tym[0] == i){ ciekawosc_tym--; } if(tab_tym[4] == i){ ciekawosc_tym--; } if(tab_tym[0] == i and tab_tym[1] == i and tab_tym[2] == i){ ciekawosc_tym++; } if(tab_tym[4] == i and tab_tym[3] == i and tab_tym[2] == i){ ciekawosc_tym++; } if(ciekawosc_tym == 0){ ciekawosc_tym++; } if(ciekawosc_tym <= k){ ciekawosc[ciekawosc_tym-1]++; } } } for(int i = 0; i < k; i++){ cout << ciekawosc[i] << " "; } delete [] ciekawosc; delete [] pomalowane1; delete [] pomalowane2; delete [] kolory2; delete [] kolory1; 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 | #include <iostream> using namespace std; int main(){ int n, k; cin >> n >> k; int *kolory1 = new int [n]; int *kolory2 = new int [n]; int *pomalowane1 = new int [n]; int *pomalowane2 = new int [n]; for(int i = 0; i < n; i++){ cin >> kolory1[i]; pomalowane1[i] = -1; } for(int i = 0; i < n; i++){ cin >> kolory2[i]; pomalowane2[i] = -1; } int *ciekawosc = new int [k]; for(int i = 0; i < k; i++){ ciekawosc[i] = 0; } int ciekawosc_tym = 0; for(int i = 0; i < 2*n; i++){ ciekawosc_tym = 0; for(int j = i; j < 2*n;j++){ int l = 0; while(kolory1[l] != j + 1 and kolory2[l] != j + 1){ l++; } int tab_tym[5]; // otoczenie 0 lewa, 1 lewa skos, 2 dół/góra, 3 prawa skos, 4 prawy if(kolory1[l] == j + 1){ pomalowane1[l] = i; if(l == 0){ tab_tym[0] = pomalowane1[n-1]; tab_tym[1] = pomalowane2[n-1]; } else{ tab_tym[0] = pomalowane1[l-1]; tab_tym[1] = pomalowane2[l-1]; } tab_tym[2] = pomalowane2[l]; if(l == n-1){ tab_tym[3] = pomalowane2[0]; tab_tym[4] = pomalowane1[0]; } else{ tab_tym[3] = pomalowane2[l+1]; tab_tym[4] = pomalowane1[l+1]; } } if(kolory2[l] == j + 1){ pomalowane2[l] = i; if(l == 0){ tab_tym[0] = pomalowane2[n-1]; tab_tym[1] = pomalowane1[n-1]; } else{ tab_tym[0] = pomalowane2[l-1]; tab_tym[1] = pomalowane1[l-1]; } tab_tym[2] = pomalowane1[l]; if(l == n-1){ tab_tym[3] = pomalowane1[0]; tab_tym[4] = pomalowane2[0]; } else{ tab_tym[3] = pomalowane1[l+1]; tab_tym[4] = pomalowane2[l+1]; } } ciekawosc_tym++; if(tab_tym[2] == i){ ciekawosc_tym--; } if(tab_tym[0] == i){ ciekawosc_tym--; } if(tab_tym[4] == i){ ciekawosc_tym--; } if(tab_tym[0] == i and tab_tym[1] == i and tab_tym[2] == i){ ciekawosc_tym++; } if(tab_tym[4] == i and tab_tym[3] == i and tab_tym[2] == i){ ciekawosc_tym++; } if(ciekawosc_tym == 0){ ciekawosc_tym++; } if(ciekawosc_tym <= k){ ciekawosc[ciekawosc_tym-1]++; } } } for(int i = 0; i < k; i++){ cout << ciekawosc[i] << " "; } delete [] ciekawosc; delete [] pomalowane1; delete [] pomalowane2; delete [] kolory2; delete [] kolory1; return 0; } |