Submission #7478122


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define PER(i,n) for (int i=(N-1);i>=0;--i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;


int main(){
  int N;
  cin >> N;

  vector<P_ii> v;
  for(int i = 2; i <= N; i++){
    printf("? %d %d\n", 1, i);

    ll dist;
    cin >> dist;

    v.push_back({dist, i});
  }
  sort(all(v), greater<>());

  vector<pair<ll, P_ii>> v2;

  v2.push_back({v[0].first, {1, v[0].second}});
  for(int i = 0; i < v.size(); i++) {
    for(int j = i + 1; j < v.size(); j++) {
      v2.push_back({v[i].first + v[j].second, {v[i].second, v[j].second}});
    }
  }
  sort(all(v2), greater<>());

  for(int i = 0; i < v2.size(); i++) {
    ll d = v2[i].first;
    auto p = v2[i].second;

    printf("? %d %d\n", p.first, p.second);

    ll dist;
    cin >> dist;

    if(d == dist){
      cout << "! " << d << endl;
      break;
    }
  }

  return 0;
}

Submission Info

Submission Time
Task D - 高橋くんと木の直径
User azz
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2219 Byte
Status
Exec Time 53 ms
Memory 852 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:76:42: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
     printf("? %d %d\n", p.first, p.second);
                                          ^
./Main.cpp:76:42: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long long int’ [-Wformat=]

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0_0.txt
Subtask1 0 / 20 subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_2.txt, subtask1_20.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt, subtask0_0.txt
All 0 / 80 subtask0_0.txt, subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_2.txt, subtask1_20.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt, subtask2_0.txt, subtask2_1.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_2.txt, subtask2_3.txt, subtask2_4.txt, subtask2_5.txt, subtask2_6.txt, subtask2_7.txt, subtask2_8.txt, subtask2_9.txt
Case Name Status Exec Time Memory
subtask0_0.txt 3 ms 696 KB
subtask1_0.txt 49 ms 848 KB
subtask1_1.txt 29 ms 720 KB
subtask1_10.txt 7 ms 848 KB
subtask1_11.txt 7 ms 720 KB
subtask1_12.txt 53 ms 720 KB
subtask1_13.txt 27 ms 848 KB
subtask1_14.txt 9 ms 720 KB
subtask1_15.txt 7 ms 844 KB
subtask1_16.txt 50 ms 848 KB
subtask1_17.txt 51 ms 848 KB
subtask1_18.txt 20 ms 720 KB
subtask1_19.txt 7 ms 848 KB
subtask1_2.txt 10 ms 724 KB
subtask1_20.txt 3 ms 652 KB
subtask1_3.txt 7 ms 848 KB
subtask1_4.txt 34 ms 716 KB
subtask1_5.txt 14 ms 724 KB
subtask1_6.txt 7 ms 848 KB
subtask1_7.txt 7 ms 852 KB
subtask1_8.txt 43 ms 848 KB
subtask1_9.txt 15 ms 720 KB
subtask2_0.txt 7 ms 844 KB
subtask2_1.txt 7 ms 844 KB
subtask2_10.txt 7 ms 848 KB
subtask2_11.txt 7 ms 848 KB
subtask2_12.txt 7 ms 852 KB
subtask2_13.txt 7 ms 848 KB
subtask2_14.txt 7 ms 848 KB
subtask2_15.txt 7 ms 720 KB
subtask2_16.txt 7 ms 716 KB
subtask2_17.txt 7 ms 844 KB
subtask2_18.txt 7 ms 848 KB
subtask2_19.txt 7 ms 724 KB
subtask2_2.txt 7 ms 720 KB
subtask2_3.txt 7 ms 852 KB
subtask2_4.txt 7 ms 724 KB
subtask2_5.txt 7 ms 848 KB
subtask2_6.txt 7 ms 848 KB
subtask2_7.txt 7 ms 848 KB
subtask2_8.txt 7 ms 848 KB
subtask2_9.txt 8 ms 848 KB