fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  4. int main()
  5. {
  6. fast;
  7. int t;
  8. cin >> t;
  9. while(t--)
  10. {
  11. long long nr,ng,nb,i,j,k;
  12. cin >> nr >> ng >> nb;
  13. long long rmx,rmd = 1e9 + 5,rmn,a[nr],b[ng],c[nb],diff = 1e9 + 5;
  14. vector<long long> s;
  15. for(i = 0; i < nr; i++)
  16. cin >> a[i];
  17. for(i = 0; i < ng; i++)
  18. cin >> b[i];
  19. for(i = 0; i < nb; i++)
  20. cin >> c[i];
  21. i = j = k = 0;
  22. sort(a,a + nr);
  23. sort(b,b + ng);
  24. sort(c,c + nb);
  25. while(i < nr && j < ng && k < nb)
  26. {
  27. long long mx = max(a[i],max(b[j],c[k]));
  28. long long mn = min(a[i],min(b[j],c[k]));
  29. long long sum = a[i] + b[j] + c[k];
  30. if(mx - mn < diff)
  31. {
  32. s.clear();
  33. diff = (mx - mn);
  34. rmx = mx;
  35. rmn = mn;
  36. rmd = sum - (mx + mn);
  37. if(rmd == a[i])
  38. s.push_back(0);
  39. if(rmd == b[j])
  40. s.push_back(1);
  41. if(rmd == c[k])
  42. s.push_back(2);
  43. }
  44. if(mn == a[i])
  45. i++;
  46. else if(mn == b[j])
  47. j++;
  48. else
  49. k++;
  50. }
  51. long long ans = 2e18;
  52. for(k = 0; k < s.size(); k++){
  53. if(s[k] == 0)
  54. {
  55. for(i = 0; i < nr; i++)
  56. ans = min(ans,(rmx - a[i])*(rmx - a[i]) + (a[i] - rmn)*(a[i] - rmn) + (rmx - rmn)*(rmx - rmn));
  57. }
  58. else if(s[k] == 1)
  59. {
  60. for(i = 0; i < ng; i++)
  61. ans = min(ans,(rmx - b[i])*(rmx - b[i]) + (b[i] - rmn)*(b[i] - rmn) + (rmx - rmn)*(rmx - rmn));
  62. }
  63. else
  64. {
  65. for(i = 0; i < nb; i++)
  66. ans = min(ans,(rmx - c[i])*(rmx - c[i]) + (c[i] - rmn)*(c[i] - rmn) + (rmx - rmn)*(rmx - rmn));
  67. }
  68. }
  69. cout<<ans<<"\n";
  70. }
  71. return 0;
  72. }
  73.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1
4 5 6
5 4 3 2 
6 8 9 10 11 
5 15 16 17 18 19 
compilation info
Main.java:1: error: illegal character: '#'
#include<bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include<bits/stdc++.h>
        ^
Main.java:3: error: illegal character: '#'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
^
Main.java:3: error: class, interface, or enum expected
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        ^
Main.java:3: error: class, interface, or enum expected
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
                                              ^
Main.java:3: error: class, interface, or enum expected
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
                                                            ^
Main.java:7: error: class, interface, or enum expected
  int t;
  ^
Main.java:8: error: class, interface, or enum expected
  cin >> t;
  ^
Main.java:9: error: class, interface, or enum expected
  while(t--)
  ^
Main.java:12: error: class, interface, or enum expected
    cin >> nr >> ng >> nb;
    ^
Main.java:13: error: class, interface, or enum expected
    long long rmx,rmd = 1e9 + 5,rmn,a[nr],b[ng],c[nb],diff = 1e9 + 5;
    ^
Main.java:14: error: class, interface, or enum expected
    vector<long long> s;
    ^
Main.java:15: error: class, interface, or enum expected
    for(i = 0; i < nr; i++)
    ^
Main.java:15: error: class, interface, or enum expected
    for(i = 0; i < nr; i++)
               ^
Main.java:15: error: class, interface, or enum expected
    for(i = 0; i < nr; i++)
                       ^
Main.java:17: error: class, interface, or enum expected
    for(i = 0; i < ng; i++)
    ^
Main.java:17: error: class, interface, or enum expected
    for(i = 0; i < ng; i++)
               ^
Main.java:17: error: class, interface, or enum expected
    for(i = 0; i < ng; i++)
                       ^
Main.java:19: error: class, interface, or enum expected
    for(i = 0; i < nb; i++)
    ^
Main.java:19: error: class, interface, or enum expected
    for(i = 0; i < nb; i++)
               ^
Main.java:19: error: class, interface, or enum expected
    for(i = 0; i < nb; i++)
                       ^
Main.java:21: error: class, interface, or enum expected
    i = j = k = 0;
    ^
Main.java:22: error: class, interface, or enum expected
    sort(a,a + nr);
    ^
Main.java:23: error: class, interface, or enum expected
    sort(b,b + ng);
    ^
Main.java:24: error: class, interface, or enum expected
    sort(c,c + nb);
    ^
Main.java:25: error: class, interface, or enum expected
    while(i < nr && j < ng && k < nb)
    ^
Main.java:28: error: class, interface, or enum expected
      long long mn = min(a[i],min(b[j],c[k]));
      ^
Main.java:29: error: class, interface, or enum expected
      long long sum = a[i] + b[j] + c[k];
      ^
Main.java:30: error: class, interface, or enum expected
      if(mx - mn < diff)
      ^
Main.java:33: error: class, interface, or enum expected
        diff = (mx - mn);
        ^
Main.java:34: error: class, interface, or enum expected
        rmx = mx;
        ^
Main.java:35: error: class, interface, or enum expected
        rmn = mn;
        ^
Main.java:36: error: class, interface, or enum expected
        rmd = sum - (mx + mn);
        ^
Main.java:37: error: class, interface, or enum expected
        if(rmd == a[i])
        ^
Main.java:39: error: class, interface, or enum expected
        if(rmd == b[j])
        ^
Main.java:41: error: class, interface, or enum expected
        if(rmd == c[k])
        ^
Main.java:43: error: class, interface, or enum expected
      }
      ^
Main.java:46: error: class, interface, or enum expected
      else if(mn == b[j])
      ^
Main.java:48: error: class, interface, or enum expected
      else
      ^
Main.java:50: error: class, interface, or enum expected
    }
    ^
Main.java:52: error: class, interface, or enum expected
    for(k = 0;  k < s.size(); k++){
    ^
Main.java:52: error: class, interface, or enum expected
    for(k = 0;  k < s.size(); k++){
                ^
Main.java:52: error: class, interface, or enum expected
    for(k = 0;  k < s.size(); k++){
                              ^
Main.java:55: error: class, interface, or enum expected
        for(i = 0; i < nr; i++)
                   ^
Main.java:55: error: class, interface, or enum expected
        for(i = 0; i < nr; i++)
                           ^
Main.java:57: error: class, interface, or enum expected
    }
    ^
Main.java:60: error: class, interface, or enum expected
        for(i = 0; i < ng; i++)
                   ^
Main.java:60: error: class, interface, or enum expected
        for(i = 0; i < ng; i++)
                           ^
Main.java:62: error: class, interface, or enum expected
    }
    ^
Main.java:65: error: class, interface, or enum expected
        for(i = 0; i < nb; i++)
                   ^
Main.java:65: error: class, interface, or enum expected
        for(i = 0; i < nb; i++)
                           ^
Main.java:67: error: class, interface, or enum expected
    }
    ^
Main.java:70: error: class, interface, or enum expected
  }
  ^
Main.java:72: error: class, interface, or enum expected
}
^
54 errors
stdout
Standard output is empty