fork download
  1. #include <bits/stdc++.h>
  2. #include <boost/algorithm/string.hpp>
  3. using namespace std;
  4.  
  5. int puntos(vector<pair<int,int>> vec){
  6. double cantidades[700];
  7. vector<pair<double,double>> resultados;
  8. //int l = 0;
  9. memset(cantidades,0,sizeof cantidades);
  10. for(int i = 0; i != vec.size(); i++){
  11. double x1 = vec.at(i).first;
  12. double y1 = vec.at(i).second;
  13. for(int j = i + 1; j != vec.size(); j++){
  14. if(i != j){
  15. double x2 = vec.at(j).first;
  16. double y2 = vec.at(j).second;
  17. double pendiente = ((y2 - y1) / (x2 - x1));
  18. double ordenada = (y1 - (pendiente * x1));
  19. //cout << "p1:(" << x1 << "," << y1 << "), p2:(" << x2 << "," << y2 << "), pendiente: " << pendiente << " ,ordenada: " << ordenada << endl;
  20. //pendientes[l] = pendiente;
  21. resultados.push_back(pair<double,double> (pendiente,ordenada));
  22. //l++;
  23. }
  24. }
  25. }
  26. for(int i = 0; i != vec.size(); i++){
  27. for(int j = 0; j != vec.size(); j++){
  28. if(i != j){
  29. if((resultados.at(i).first == resultados.at(j).first) && (resultados.at(i).second == resultados.at(j).second)){
  30. cantidades[i]++;
  31. }
  32. }
  33. }
  34. }
  35. int max = -1;
  36. for(int i = 0; i != resultados.size(); i++){
  37. if(cantidades[i] > max){
  38. max = cantidades[i];
  39. }
  40. }
  41. return max + 1;
  42. }
  43.  
  44. int main() {
  45. int casos, x, y;
  46. cin >> casos;
  47. string linea;
  48. getline(cin,linea);
  49. getline(cin,linea);
  50. while(getline(cin,linea) && linea != ""){
  51. vector<string> linea1;
  52. vector<pair<int,int>> vec;
  53. boost::split(linea1, linea, [](char c){return c == ' ';});
  54. int x = stoi(linea1[0]);
  55. int y = stoi(linea1[1]);
  56. vec.push_back(pair<int,int> (x,y));
  57. while(getline(cin,linea) && linea != ""){
  58. boost::split(linea1, linea, [](char c){return c == ' ';});
  59. int x = stoi(linea1[0]);
  60. int y = stoi(linea1[1]);
  61. vec.push_back(pair<int,int> (x,y));
  62. }
  63. cout << puntos(vec) << endl << endl;
  64. }
  65. return 0;
  66. }
Success #stdin #stdout 0s 15256KB
stdin
2

1 1
2 2
3 3
9 10
10 11

1 1
2 2
3 3
9 10
10 11
stdout
3

3