Niestety, nie byliśmy w stanie w pełni poprawnie wyświetlić tego pliku, ponieważ nie jest zakodowany w UTF-8.
Możesz pobrać ten plik i spróbować otworzyć go samodzielnie.
// Artur Kraska, II UWr #include <bits/stdc++.h> #define forr(i, n) for(int i=0; i<n; i++) #define FOREACH(iter, coll) for(auto iter = coll.begin(); iter != coll.end(); ++iter) #define FOREACHR(iter, coll) for(auto iter = coll.rbegin(); iter != coll.rend(); ++iter) #define lbound(P,R,PRED) ({typeof(P) X=P,RRR=(R), PPP = P; while(PPP<RRR) {X = (PPP+(RRR-PPP)/2); if(PRED) RRR = X; else PPP = X+1;} PPP;}) #define testy() int _tests; scanf("%d", &_tests); FOR(_test, 1, _tests) #define CLEAR(tab) memset(tab, 0, sizeof(tab)) #define CONTAIN(el, coll) (coll.find(el) != coll.end()) #define FOR(i, a, b) for(int i=a; i<=b; i++) #define FORD(i, a, b) for(int i=a; i>=b; i--) #define MP make_pair #define PB push_back #define deb(X) X; #define M 1000000007 #define INF 1000000007 using namespace std; int n, m, a; int d1, d2, d, t1[1000007], t2[1000007], tt[2000517], *t; vector <int> v1, v2; long long fib[107]; void brut() { fib[0] = fib[1] = 1; FOR(i, 2, 100) fib[i] = fib[i-1] + fib[i-2]; long long a, b; //scanf("%d", &n); n = 0; while(n--) { scanf("%lld %lld", &a, &b); a *= b; FORD(i, 30, 0) if(a >= fib[i]) { a -= fib[i]; cout << 1; } else cout << 0; cout << endl; } FOR(i, 1, 20) FOR(j, 1, i) { printf("%2d %2d: ", i, j); a = fib[i]*fib[j]; FORD(i, 40, 0) if(a >= fib[i]) { a -= fib[i]; cout << '#'; } else cout << '.'; cout << endl; } } int main() { t = tt+100; //brut(); testy() { v1.clear(); v2.clear(); scanf("%d", &d1); d1++; FOR(i, 2, d1) { scanf("%d", &a); if(a == 1) v1.PB(i-1); } scanf("%d", &d2); d2++; FOR(i, 2, d2) { scanf("%d", &a); if(a == 1) v2.PB(i-1); } d = d1+d2+100; FOR(i, -10, d+110) t[i] = 0; // zamiast tej p�tli pewnie trzeba dac jakies FFT :P for(auto i : v1) for(auto j : v2) { int y = i+j-1; t[y]++; int x = min(i, j)+1; if((x&1) == 0) t[y-x*2]--; else { y = y-((x-1)*2); t[y]--; t[y+1]++; t[y-3]--; } } FORD(i, d, 0) t[i] += t[i+4]; t[1] += t[0]; t[0] = 0; // normalizacja int poz = d; do { while(poz > 0) { // cout << "poz: " << poz << ", t[poz] = " << t[poz] << ", t[poz-1] = " << t[poz-1] << endl; if(t[poz] > 0 && t[poz-1] > 0) { int x = min(t[poz], t[poz-1]); t[poz] -= x; t[poz-1] -= x; t[poz+1] += x; poz+=2; } else if(t[poz] > 1) { int x = t[poz]/2; t[poz] -= 2*x; t[poz+1] += x; t[poz-2] += x; poz+=2; } else poz--; } if(poz == 0 && t[poz] > 0) { t[1] += t[0]; t[0] = 0; poz += 2; } } while (poz > 0); while(t[d] == 0) d--; //long long res = 0; printf("%d", d); FOR(i, 1, d) { //if(t[i]) // res += fib[i]; printf(" %d", t[i]); } printf("\n"); //printf(" %2lld * %2lld = %2lld (%2lld)\n", fib[i], fib[j], res, fib[i]*fib[j]); //if(res != fib[i]*fib[j]) // cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! BLAAAAAAAAADDDDDDDDD !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; //FOR(i, -10, 5) // cout << i << " -> " << t[i] << 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | // Artur Kraska, II UWr #include <bits/stdc++.h> #define forr(i, n) for(int i=0; i<n; i++) #define FOREACH(iter, coll) for(auto iter = coll.begin(); iter != coll.end(); ++iter) #define FOREACHR(iter, coll) for(auto iter = coll.rbegin(); iter != coll.rend(); ++iter) #define lbound(P,R,PRED) ({typeof(P) X=P,RRR=(R), PPP = P; while(PPP<RRR) {X = (PPP+(RRR-PPP)/2); if(PRED) RRR = X; else PPP = X+1;} PPP;}) #define testy() int _tests; scanf("%d", &_tests); FOR(_test, 1, _tests) #define CLEAR(tab) memset(tab, 0, sizeof(tab)) #define CONTAIN(el, coll) (coll.find(el) != coll.end()) #define FOR(i, a, b) for(int i=a; i<=b; i++) #define FORD(i, a, b) for(int i=a; i>=b; i--) #define MP make_pair #define PB push_back #define deb(X) X; #define M 1000000007 #define INF 1000000007 using namespace std; int n, m, a; int d1, d2, d, t1[1000007], t2[1000007], tt[2000517], *t; vector <int> v1, v2; long long fib[107]; void brut() { fib[0] = fib[1] = 1; FOR(i, 2, 100) fib[i] = fib[i-1] + fib[i-2]; long long a, b; //scanf("%d", &n); n = 0; while(n--) { scanf("%lld %lld", &a, &b); a *= b; FORD(i, 30, 0) if(a >= fib[i]) { a -= fib[i]; cout << 1; } else cout << 0; cout << endl; } FOR(i, 1, 20) FOR(j, 1, i) { printf("%2d %2d: ", i, j); a = fib[i]*fib[j]; FORD(i, 40, 0) if(a >= fib[i]) { a -= fib[i]; cout << '#'; } else cout << '.'; cout << endl; } } int main() { t = tt+100; //brut(); testy() { v1.clear(); v2.clear(); scanf("%d", &d1); d1++; FOR(i, 2, d1) { scanf("%d", &a); if(a == 1) v1.PB(i-1); } scanf("%d", &d2); d2++; FOR(i, 2, d2) { scanf("%d", &a); if(a == 1) v2.PB(i-1); } d = d1+d2+100; FOR(i, -10, d+110) t[i] = 0; // zamiast tej p�tli pewnie trzeba dac jakies FFT :P for(auto i : v1) for(auto j : v2) { int y = i+j-1; t[y]++; int x = min(i, j)+1; if((x&1) == 0) t[y-x*2]--; else { y = y-((x-1)*2); t[y]--; t[y+1]++; t[y-3]--; } } FORD(i, d, 0) t[i] += t[i+4]; t[1] += t[0]; t[0] = 0; // normalizacja int poz = d; do { while(poz > 0) { // cout << "poz: " << poz << ", t[poz] = " << t[poz] << ", t[poz-1] = " << t[poz-1] << endl; if(t[poz] > 0 && t[poz-1] > 0) { int x = min(t[poz], t[poz-1]); t[poz] -= x; t[poz-1] -= x; t[poz+1] += x; poz+=2; } else if(t[poz] > 1) { int x = t[poz]/2; t[poz] -= 2*x; t[poz+1] += x; t[poz-2] += x; poz+=2; } else poz--; } if(poz == 0 && t[poz] > 0) { t[1] += t[0]; t[0] = 0; poz += 2; } } while (poz > 0); while(t[d] == 0) d--; //long long res = 0; printf("%d", d); FOR(i, 1, d) { //if(t[i]) // res += fib[i]; printf(" %d", t[i]); } printf("\n"); //printf(" %2lld * %2lld = %2lld (%2lld)\n", fib[i], fib[j], res, fib[i]*fib[j]); //if(res != fib[i]*fib[j]) // cout << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! BLAAAAAAAAADDDDDDDDD !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; //FOR(i, -10, 5) // cout << i << " -> " << t[i] << endl; } return 0; } |