AtCoder Beginner Contest 019

Submission #7478143

Source codeソースコード

#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].first, {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

Task問題 D - 高橋くんと木の直径
User nameユーザ名 azz
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 2218 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

./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=]

Test case

Set

Set name Score得点 / Max score Cases
Sample - 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask0_0.txt AC 3 ms 720 KB
subtask1_0.txt WA
subtask1_1.txt AC 43 ms 720 KB
subtask1_10.txt WA
subtask1_11.txt AC 14 ms 724 KB
subtask1_12.txt WA
subtask1_13.txt AC 6 ms 852 KB
subtask1_14.txt AC 5 ms 720 KB
subtask1_15.txt WA
subtask1_16.txt AC 5 ms 848 KB
subtask1_17.txt AC 5 ms 720 KB
subtask1_18.txt AC 5 ms 716 KB
subtask1_19.txt AC 5 ms 844 KB
subtask1_2.txt WA
subtask1_20.txt AC 3 ms 716 KB
subtask1_3.txt WA
subtask1_4.txt AC 31 ms 720 KB
subtask1_5.txt AC 29 ms 848 KB
subtask1_6.txt AC 31 ms 852 KB
subtask1_7.txt AC 28 ms 848 KB
subtask1_8.txt WA
subtask1_9.txt WA
subtask2_0.txt WA
subtask2_1.txt WA
subtask2_10.txt WA
subtask2_11.txt WA
subtask2_12.txt AC 5 ms 848 KB
subtask2_13.txt AC 6 ms 712 KB
subtask2_14.txt WA
subtask2_15.txt WA
subtask2_16.txt AC 5 ms 720 KB
subtask2_17.txt AC 5 ms 848 KB
subtask2_18.txt AC 5 ms 716 KB
subtask2_19.txt AC 5 ms 720 KB
subtask2_2.txt AC 6 ms 720 KB
subtask2_3.txt WA
subtask2_4.txt WA
subtask2_5.txt WA
subtask2_6.txt WA
subtask2_7.txt WA
subtask2_8.txt WA
subtask2_9.txt WA