답안 #85377

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
85377 2018-11-19T14:09:11 Z tjdgus4384 조화행렬 (KOI18_matrix) C++14
0 / 100
9 ms 500 KB
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<int, pair<int, int> > > v;
vector<int> vf;
vector<int> vs;

int main()
{
    int m, n, x;
    scanf("%d %d",&m, &n);
    v.resize(n);
    for(int i = 0;i < m;i++)
    {
        for(int j = 0;j < n;j++)
        {
            scanf("%d", &x);
            if(i == 0) v[j].first = x;
            if(i == 1) v[j].second.first = x;
            if(i == 2) v[j].second.second = x;
            if(i == 0 && m == 2) v[j].second.second = v[j].first;
        }
    }
    sort(v.begin(), v.end());
    vf.push_back({-1000000000});
    vs.push_back({-1000000000});
    for(int i = 0;i < n;i++)
    {
        int f = v[i].second.first;
        int s = v[i].second.second;
        if(f > vf.back() && s > vs.back())
        {
            vf.push_back(f);
            vs.push_back(s);
        }
        else
        {
            int fx = lower_bound(vf.begin(), vf.end(), f) - vf.begin();
            int sx = lower_bound(vs.begin(), vs.end(), s) - vs.begin();
            fx = max(fx, sx);
            sx = fx;
            vf[fx] = f;
            vs[sx] = s;
        }
    }
    printf("%d", vf.size() - 1);
    return 0;
}

Compilation message

matrix.cpp: In function 'int main()':
matrix.cpp:47:31: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d", vf.size() - 1);
                  ~~~~~~~~~~~~~^
matrix.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&m, &n);
     ~~~~~^~~~~~~~~~~~~~~~
matrix.cpp:18:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &x);
             ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 500 KB Output isn't correct
2 Halted 0 ms 0 KB -