#4005
cutting
Aveți o foaie de hârtie dreptunghiulară cu dimensiunile N x M
centimetri. Foaia este împărțită într-o rețea de pătrate de 1 x 1
centimetri fiecare. Puteți considera foaia ca un sistem de coordonate – colțul din stânga jos este originea (0,0)
a sistemului de coordonate și fiecărui vârf al unui pătrat îi sunt atribuite coordonate întregi – între 0
și N
pe axa x
și între 0
și M
pe axa y
. Primiți o succesiune de cereri de tăiere a foii de hârtie (sau mai exact, a părții care a mai rămas din ea). Fiecare cerere este definită de o pereche de numere întregi nenegative (p, q)
, reprezentând un punct din rețea, care este situat în porțiunea netăiată a hârtiei. Scrieți un program care după fiecare cerere calculează aria figurii rămase.
Problema | cutting | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.5 secunde | Limita memorie |
Total: 512 MB
/
Stivă 64 MB
|
Id soluție | #38988721 | Utilizator | |
Fișier | cutting.cpp | Dimensiune | 4.91 KB |
Data încărcării | 23 Octombrie 2022, 23:37 | Scor / rezultat | Eroare de compilare |
cutting.cpp: In function 'double area(segment)': cutting.cpp:17:27: error: call of overloaded 'abs(double)' is ambiguous return abs(a.xst-a.xdr)*min(a.yst,a.ydr)*2+abs(a.ydr-a.yst)*abs(a.xst-a.xdr); ^ cutting.cpp:17:27: note: candidates are: In file included from /usr/include/c++/4.8/cstdlib:72:0, from /usr/include/c++/4.8/ext/string_conversions.h:41, from /usr/include/c++/4.8/bits/basic_string.h:2815, from /usr/include/c++/4.8/string:52, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from cutting.cpp:1: /usr/include/stdlib.h:775:12: note: int abs(int) extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; ^ In file included from /usr/include/c++/4.8/ext/string_conversions.h:41:0, from /usr/include/c++/4.8/bits/basic_string.h:2815, from /usr/include/c++/4.8/string:52, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from cutting.cpp:1: /usr/include/c++/4.8/cstdlib:174:3: note: long long int std::abs(long long int) abs(long long __x) { return __builtin_llabs (__x); } ^ /usr/include/c++/4.8/cstdlib:166:3: note: long int std::abs(long int) abs(long __i) { return __builtin_labs(__i); } ^ cutting.cpp:17:63: error: call of overloaded 'abs(double)' is ambiguous return abs(a.xst-a.xdr)*min(a.yst,a.ydr)*2+abs(a.ydr-a.yst)*abs(a.xst-a.xdr); ^ cutting.cpp:17:63: note: candidates are: In file included from /usr/include/c++/4.8/cstdlib:72:0, from /usr/include/c++/4.8/ext/string_conversions.h:41, from /usr/include/c++/4.8/bits/basic_string.h:2815, from /usr/include/c++/4.8/string:52, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from cutting.cpp:1: /usr/include/stdlib.h:775:12: note: int abs(int) extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; ^ In file included from /usr/include/c++/4.8/ext/string_conversions.h:41:0, from /usr/include/c++/4.8/bits/basic_string.h:2815, from /usr/include/c++/4.8/string:52, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from cutting.cpp:1: /usr/include/c++/4.8/cstdlib:174:3: note: long long int std::abs(long long int) abs(long long __x) { return __builtin_llabs (__x); } ^ /usr/include/c++/4.8/cstdlib:166:3: note: long int std::abs(long int) abs(long __i) { return __builtin_labs(__i); } ^ cutting.cpp:17:80: error: call of overloaded 'abs(double)' is ambiguous return abs(a.xst-a.xdr)*min(a.yst,a.ydr)*2+abs(a.ydr-a.yst)*abs(a.xst-a.xdr); ^ cutting.cpp:17:80: note: candidates are: In file included from /usr/include/c++/4.8/cstdlib:72:0, from /usr/include/c++/4.8/ext/string_conversions.h:41, from /usr/include/c++/4.8/bits/basic_string.h:2815, from /usr/include/c++/4.8/string:52, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from cutting.cpp:1: /usr/include/stdlib.h:775:12: note: int abs(int) extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; ^ In file included from /usr/include/c++/4.8/ext/string_conversions.h:41:0, from /usr/include/c++/4.8/bits/basic_string.h:2815, from /usr/include/c++/4.8/string:52, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from cutting.cpp:1: /usr/include/c++/4.8/cstdlib:174:3: note: long long int std::abs(long long int) abs(long long __x) { return __builtin_llabs (__x); } ^ /usr/include/c++/4.8/cstdlib:166:3: note: long int std::abs(long int) abs(long __i) { return __builtin_labs(__i); } ^ cutting.cpp: In function 'void adauga(int, int)': cutting.cpp:79:52: warning: narrowing conversion of 'std::max<int>((* &0), (* &((x - m) + y)))' from 'const int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{max(0,x-m+y),m,x,y,x-m+y});///in stanga ^ cutting.cpp:79:52: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:79:52: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:79:52: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:79:50: warning: narrowing conversion of '((x - m) + y)' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{max(0,x-m+y),m,x,y,x-m+y});///in stanga ^ cutting.cpp:80:53: warning: narrowing conversion of 'std::max<int>((* &0), (* &((x - m) + y)))' from 'const int' to 'double' inside { } [-Wnarrowing] it=seg.find(segment{max(0,x-m+y),m,x,y,x-m+y}); ^ cutting.cpp:80:53: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:80:53: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:80:53: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:80:51: warning: narrowing conversion of '((x - m) + y)' from 'int' to 'double' inside { } [-Wnarrowing] it=seg.find(segment{max(0,x-m+y),m,x,y,x-m+y}); ^ cutting.cpp:81:62: warning: narrowing conversion of 'std::max<int>((* &0), (* &((x - m) + y)))' from 'const int' to 'double' inside { } [-Wnarrowing] rez=intersection(*it,segment{max(0,x-m+y),m,x,y,x-m+y}); ^ cutting.cpp:81:62: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:81:62: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:81:62: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:81:60: warning: narrowing conversion of '((x - m) + y)' from 'int' to 'double' inside { } [-Wnarrowing] rez=intersection(*it,segment{max(0,x-m+y),m,x,y,x-m+y}); ^ cutting.cpp:87:66: warning: narrowing conversion of 'std::max<int>((* &0), (* &((x - m) + y)))' from 'const int' to 'double' inside { } [-Wnarrowing] rez=intersection(*it,segment{max(0,x-m+y),m,x,y,x-m+y}); ^ cutting.cpp:87:66: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:87:66: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:87:66: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:87:64: warning: narrowing conversion of '((x - m) + y)' from 'int' to 'double' inside { } [-Wnarrowing] rez=intersection(*it,segment{max(0,x-m+y),m,x,y,x-m+y}); ^ cutting.cpp:91:62: warning: narrowing conversion of 'std::max<int>((* &0), (* &((x - m) + y)))' from 'const int' to 'double' inside { } [-Wnarrowing] rez=intersection(cop,segment{max(0,x-m+y),m,x,y,x-m+y}); ^ cutting.cpp:91:62: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:91:62: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:91:62: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:91:60: warning: narrowing conversion of '((x - m) + y)' from 'int' to 'double' inside { } [-Wnarrowing] rez=intersection(cop,segment{max(0,x-m+y),m,x,y,x-m+y}); ^ cutting.cpp:95:64: warning: narrowing conversion of 'rez.std::pair<int, int>::first' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{rez.first,rez.second, x,y, x-m+y}); ^ cutting.cpp:95:64: warning: narrowing conversion of 'rez.std::pair<int, int>::second' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:95:64: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:95:64: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:95:62: warning: narrowing conversion of '((x - m) + y)' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{rez.first,rez.second, x,y, x-m+y}); ^ cutting.cpp:96:80: warning: narrowing conversion of 'rez.std::pair<int, int>::first' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{cop.xst,cop.yst, rez.first,rez.second, cop.xdown}); ^ cutting.cpp:96:80: warning: narrowing conversion of 'rez.std::pair<int, int>::second' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:97:56: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{x,m,cop.xdr,m, cop.xdown}); ^ cutting.cpp:97:56: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:97:56: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:101:64: warning: narrowing conversion of 'rez.std::pair<int, int>::first' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{rez.first,rez.second, x,y, x-m+y}); ^ cutting.cpp:101:64: warning: narrowing conversion of 'rez.std::pair<int, int>::second' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:101:64: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:101:64: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:101:62: warning: narrowing conversion of '((x - m) + y)' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{rez.first,rez.second, x,y, x-m+y}); ^ cutting.cpp:102:80: warning: narrowing conversion of 'rez.std::pair<int, int>::first' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{cop.xst,cop.yst, rez.first,rez.second, cop.xdown}); ^ cutting.cpp:102:80: warning: narrowing conversion of 'rez.std::pair<int, int>::second' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:107:52: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{x,y,min(x+m-y,n),m,x+m-y});///in dreapta ^ cutting.cpp:107:52: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:107:52: warning: narrowing conversion of 'std::min<int>((* &((x + m) - y)), (*(const int*)(& n)))' from 'const int' to 'double' inside { } [-Wnarrowing] cutting.cpp:107:52: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:107:50: warning: narrowing conversion of '((x + m) - y)' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{x,y,min(x+m-y,n),m,x+m-y});///in dreapta ^ cutting.cpp:108:53: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] it=seg.find(segment{x,y,min(x+m-y,n),m,x+m-y}); ^ cutting.cpp:108:53: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:108:53: warning: narrowing conversion of 'std::min<int>((* &((x + m) - y)), (*(const int*)(& n)))' from 'const int' to 'double' inside { } [-Wnarrowing] cutting.cpp:108:53: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:108:51: warning: narrowing conversion of '((x + m) - y)' from 'int' to 'double' inside { } [-Wnarrowing] it=seg.find(segment{x,y,min(x+m-y,n),m,x+m-y}); ^ cutting.cpp:109:62: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] rez=intersection(*it,segment{x,y,min(x+m-y,n),m,x+m-y}); ^ cutting.cpp:109:62: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:109:62: warning: narrowing conversion of 'std::min<int>((* &((x + m) - y)), (*(const int*)(& n)))' from 'const int' to 'double' inside { } [-Wnarrowing] cutting.cpp:109:62: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:109:60: warning: narrowing conversion of '((x + m) - y)' from 'int' to 'double' inside { } [-Wnarrowing] rez=intersection(*it,segment{x,y,min(x+m-y,n),m,x+m-y}); ^ cutting.cpp:116:66: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] rez=intersection(*it,segment{x,y,min(x+m-y,n),m,x+m-y}); ^ cutting.cpp:116:66: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:116:66: warning: narrowing conversion of 'std::min<int>((* &((x + m) - y)), (*(const int*)(& n)))' from 'const int' to 'double' inside { } [-Wnarrowing] cutting.cpp:116:66: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:116:64: warning: narrowing conversion of '((x + m) - y)' from 'int' to 'double' inside { } [-Wnarrowing] rez=intersection(*it,segment{x,y,min(x+m-y,n),m,x+m-y}); ^ cutting.cpp:120:62: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] rez=intersection(cop,segment{x,y,min(x+m-y,n),m,x+m-y}); ^ cutting.cpp:120:62: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:120:62: warning: narrowing conversion of 'std::min<int>((* &((x + m) - y)), (*(const int*)(& n)))' from 'const int' to 'double' inside { } [-Wnarrowing] cutting.cpp:120:62: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:120:60: warning: narrowing conversion of '((x + m) - y)' from 'int' to 'double' inside { } [-Wnarrowing] rez=intersection(cop,segment{x,y,min(x+m-y,n),m,x+m-y}); ^ cutting.cpp:129:63: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{x,y, rez.first,rez.second,x+m-y}); ^ cutting.cpp:129:63: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:129:63: warning: narrowing conversion of 'rez.std::pair<int, int>::first' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:129:63: warning: narrowing conversion of 'rez.std::pair<int, int>::second' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:129:61: warning: narrowing conversion of '((x + m) - y)' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{x,y, rez.first,rez.second,x+m-y}); ^ cutting.cpp:130:79: warning: narrowing conversion of 'rez.std::pair<int, int>::first' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{rez.first,rez.second, cop.xdr,cop.ydr,cop.xdown}); ^ cutting.cpp:130:79: warning: narrowing conversion of 'rez.std::pair<int, int>::second' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:131:56: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{cop.xst,m, x,m,cop.xdown}); ^ cutting.cpp:131:56: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:131:56: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:135:63: warning: narrowing conversion of 'x' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{x,y, rez.first,rez.second,x+m-y}); ^ cutting.cpp:135:63: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:135:63: warning: narrowing conversion of 'rez.std::pair<int, int>::first' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:135:63: warning: narrowing conversion of 'rez.std::pair<int, int>::second' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:135:61: warning: narrowing conversion of '((x + m) - y)' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{x,y, rez.first,rez.second,x+m-y}); ^ cutting.cpp:136:80: warning: narrowing conversion of 'rez.std::pair<int, int>::first' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{rez.first,rez.second, cop.xdr,cop.ydr, cop.xdown}); ^ cutting.cpp:136:80: warning: narrowing conversion of 'rez.std::pair<int, int>::second' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp: In function 'int main()': cutting.cpp:143:33: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{0,0,0,m,0}); ^ cutting.cpp:144:34: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{0,m,n,m,-1}); ^ cutting.cpp:144:34: warning: narrowing conversion of 'n' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:144:34: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:145:33: warning: narrowing conversion of 'n' from 'int' to 'double' inside { } [-Wnarrowing] seg.insert(segment{n,m,n,0,n}); ^ cutting.cpp:145:33: warning: narrowing conversion of 'm' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:145:33: warning: narrowing conversion of 'n' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp:145:33: warning: narrowing conversion of 'n' from 'int' to 'double' inside { } [-Wnarrowing] cutting.cpp: In function 'double area(segment)': cutting.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type] } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema cutting face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.