답안 #726875

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
726875 2023-04-19T13:19:52 Z kerem Slagalica (COCI19_slagalica2) C++14
10 / 70
77 ms 2932 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fir first
#define sec second
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int32_t main(){
    int n,one=0,four=0,l,r,l1,r1;
    cin >> n;
    vector<int> a,b;
    while(n--){
        int x,y;
        cin >> x >> y;
        if(x==5) l=1,l1=y;
        if(x==6) l=0,l1=y;
        if(x==7) r=1,r1=y;
        if(x==8) r=0,r1=y;
        if(x==1)
            one++,a.pb(y);
        if(x==4)
            four++,b.pb(y);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(l!=r){
        if(one!=four){
            cout << -1;
            return 0;
        }
        cout << l1 << " ";
        int c,k=1;
        if(l==1)
            c=0;
        else
            c=1;
        for(int i=0;i<a.size();i++){
            if(c)
                cout << a[i] << " ";
            else
                cout << b[i] << " ";
            if(k)
                i--;
            k^=1;
            c^=1;
        }
    }
    else if(l==1){
        if(one!=four-1){
            cout << -1;
            return 0;
        }
        cout << l1 << " ";
        int c=0,k=1;
        for(int i=0;i<b.size();i++){
            if(c)
                cout << a[i] << " ";
            else
                cout << b[i] << " ";
            if(i==b.size()-1)
                break;
            if(k)
                i--;
            k^=1;
            c^=1;
        }
    }
    else if(l==0){
        if(one!=four+1){
            cout << -1;
            return 0;
        }
        cout << l1 << " ";
        int c=1,k=1;
        for(int i=0;i<a.size();i++){
            if(c)
                cout << a[i] << " ";
            else
                cout << b[i] << " ";
            if(i==a.size()-1)
                break;
            if(k)
                i--;
            k^=1;
            c^=1;
        }
    }
    cout << r1;
    return 0;
}

Compilation message

slagalica.cpp: In function 'int32_t main()':
slagalica.cpp:37:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int i=0;i<a.size();i++){
      |                     ~^~~~~~~~~
slagalica.cpp:55:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for(int i=0;i<b.size();i++){
      |                     ~^~~~~~~~~
slagalica.cpp:60:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |             if(i==b.size()-1)
      |                ~^~~~~~~~~~~~
slagalica.cpp:75:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |         for(int i=0;i<a.size();i++){
      |                     ~^~~~~~~~~
slagalica.cpp:80:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |             if(i==a.size()-1)
      |                ~^~~~~~~~~~~~
slagalica.cpp:26:5: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |     if(l!=r){
      |     ^~
slagalica.cpp:26:5: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 2932 KB Output is correct
2 Correct 61 ms 2148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 2864 KB Output is correct
2 Correct 53 ms 2212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 1428 KB Output is correct
2 Incorrect 58 ms 1288 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 1168 KB Output is correct
2 Incorrect 41 ms 1160 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 44 ms 1172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 1164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 1888 KB Output is correct
2 Incorrect 69 ms 2420 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 2552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 60 ms 2304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 2288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 50 ms 2196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 2256 KB Output isn't correct
2 Halted 0 ms 0 KB -