Submission #404247

#TimeUsernameProblemLanguageResultExecution timeMemory
404247joelau레이저 센서 (KOI16_laser)C++14
19 / 100
2 ms300 KiB
#include <bits/stdc++.h> using namespace std; int N; pair<int,int> ans[1000]; tuple<int,int,int> lst[3000]; vector< pair<int,int> > v; int main() { scanf("%d", &N); for (int i = 0; i < N; ++i) { int x,y; scanf("%d %d", &x, &y); lst[i] = make_tuple(x,0,i); } for (int i = 0; i < N*2; ++i) { int x,y; scanf("%d %d", &x, &y); lst[i+N] = make_tuple(x,1,i+1); } sort(lst,lst+N*3); for (int i = 0; i < N*3; ++i) { if (v.size() >= 2 && get<1>(lst[i]) + v.back().first + v[v.size()-2].first == 2) { if (get<1>(lst[i]) == 0) ans[get<2>(lst[i])] = make_pair(v.back().second, v[v.size()-2].second); if (v.back().first == 0) ans[v.back().second] = make_pair(get<2>(lst[i]), v[v.size()-2].second); if (v[v.size()-2].first == 0) ans[v[v.size()-2].second] = make_pair(get<2>(lst[i]), v.back().second); v.pop_back(); v.pop_back(); } else v.emplace_back(get<1>(lst[i]),get<2>(lst[i])); } if (!v.empty()) printf("-1"); else { for (int i = 0; i < N; ++i) printf("%d %d\n", ans[i].first, ans[i].second); } return 0; }

Compilation message (stderr)

laser.cpp: In function 'int main()':
laser.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
laser.cpp:12:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         int x,y; scanf("%d %d", &x, &y);
      |                  ~~~~~^~~~~~~~~~~~~~~~~
laser.cpp:16:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         int x,y; scanf("%d %d", &x, &y);
      |                  ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...