# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
109687 | 2019-05-07T13:32:21 Z | njchung99 | Matryoshka (JOI16_matryoshka) | C++14 | 3 ms | 384 KB |
#include<cstdio> #include<cstring> #include<vector> #include<algorithm> using namespace std; vector<vector<int>> vt; int dap = 0; int q, w; int de[2010]; pair<int, int> a[2010]; int visited[2010]; void dfs(int here,int depth) { visited[here] = 1; de[depth]++; for (int i = 0; i < vt[here].size(); i++) { int next = vt[here][i]; if (a[next].first >= q && a[next].second <= w&&!visited[next]) { dfs(next, depth + 1); } } } int main() { int n,m; scanf("%d %d", &n,&m); vt.resize(n + 1); for (int i = 0; i < n; i++) { scanf("%d %d", &a[i].first, &a[i].second); } sort(a, a + n); reverse(a, a + n); for (int i = 0; i < n; i++) { for (int y = 0; y < n; y++) { if (a[i].first > a[y].first&&a[i].second > a[y].second) vt[i].push_back(y); } } while(m--){ scanf("%d %d", &q, &w); memset(de, 0, sizeof(de)); memset(visited, 0, sizeof(visited)); int oo = 0; for (int i = 0; i < n; i++) { if (a[i].first >= q && a[i].second <= w&&!visited[i] ) { oo++; dfs(i,0); } } for (int i = 0; i < 2000; i++) oo = max(oo, de[i]); printf("%d\n", oo); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Incorrect | 2 ms | 256 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Incorrect | 2 ms | 256 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Incorrect | 2 ms | 256 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Incorrect | 2 ms | 256 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |