답안 #228243

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
228243 2020-04-30T09:17:43 Z VEGAnn Teoretičar (COCI18_teoreticar) C++14
0 / 130
12000 ms 91144 KB
#include <bits/stdc++.h>
#define pii pair<int,int>
#define ft first
#define sd second
#define MP make_pair
#define sz(x) ((int)x.size())
using namespace std;
typedef long long ll;
const int N = 5010;
const int M = 500100;
const int oo = 2e9;
int col[M], l, r, mrk[2][N][N], m, ans = oo, nm[M], mem[M], x[M], y[M], tt = 0;

mt19937 rnd(chrono::system_clock().now().time_since_epoch().count());

void potential(){
    shuffle(nm, nm + m, rnd);

    int cur = 0;

    tt++;

    for (int it = 0; it < m; it++){
        int i = nm[it];

        for (int c = 0; ; c++)
            if (mrk[0][x[i]][c] < tt && mrk[1][y[i]][c] < tt){
                col[i] = c;
                cur = max(cur, c);
                mrk[0][x[i]][c] = mrk[1][y[i]][c] = tt;
                break;
            }
    }

    if (ans > cur){
        ans = cur;

        for (int i = 0; i < m; i++)
            mem[i] = col[i];
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> l >> r >> m;

    for (int i = 0; i < m; i++){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
        nm[i] = i;
    }

    for (int it = 0; it < 10000; it++)
        potential();

    cout << ans + 1 << '\n';

    for (int i = 0; i < m; i++)
        cout << mem[i] + 1 << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 560 KB too many colors
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 768 KB Output is correct
2 Correct 55 ms 832 KB Output is correct
3 Correct 42 ms 896 KB Output is correct
4 Incorrect 50 ms 768 KB too many colors
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2640 ms 20608 KB too many colors
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5251 ms 12512 KB Output is correct
2 Correct 3109 ms 8824 KB Output is correct
3 Correct 2583 ms 25984 KB Output is correct
4 Incorrect 2856 ms 5500 KB too many colors
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 105 ms 11384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 95 ms 11384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 114 ms 14968 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 12005 ms 25964 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 12076 ms 91144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 12095 ms 90608 KB Time limit exceeded
2 Halted 0 ms 0 KB -