답안 #403584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403584 2021-05-13T09:49:08 Z tqbfjotld 레이저 센서 (KOI16_laser) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
using namespace std;

vector<pair<int,pair<int,int> > > points;
vector<int> ans[1005];

int main(){
    int n;
    scanf("%d",&n);
    for (int x = 0;x<n; x++){
        int a,b;
        scanf("%d%d",&a,&b);
        points.push_back({a,{x,0}});
    }
    for (int x = 0; x<2*n; x++){
        int a,b;
        scanf("%d%d",&a,&b);
        points.push_back({a,{x,1}});
    }
    sort(points.begin(),points.end());
    vector<pair<int,int> > red;
    vector<pair<int,int> > b;
    for (auto x : points){
        if (x.second.second){
            if (!b.empty()){
                ans[b.back().second].push_back(x.second.first);
                b.pop_back();
            }
            else{
                red.push_back({x.first,x.second.first});
            }
        }
        else{
            for (int k = 0; k<2; k++){
                if (!red.empty()){
                    ans[x.second.first].push_back(red.back().second);
                    red.pop_back();
                }
                else{
                    b.push_back({x.first,x.second.first});
                }
            }
        }
    }
    for (int x = 0; x<n; x++){
        printf("%d %d\n",ans[x][0],ans[x][1]);
    }
}

Compilation message

laser.cpp: In function 'int main()':
laser.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
laser.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d%d",&a,&b);
      |         ~~~~~^~~~~~~~~~~~~~
laser.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%d%d",&a,&b);
      |         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -