제출 #120063

#제출 시각아이디문제언어결과실행 시간메모리
120063thecodingwizardTeoretičar (COCI18_teoreticar)C++11
0 / 130
12101 ms76244 KiB
#include <bits/stdc++.h> using namespace std; template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>; #define FOR(i, a, b) for (int i=a; i<(b); i++) #define F0R(i, a) for (int i=0; i<(a); i++) #define F0R1(i, a) for (int i=1; i<=(a); i++) #define FORd(i, a, b) for (int i = (b)-1; i >= a; i--) #define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--) #define F0Rd1(i, a) for (int i=a; i>0; i--) #define SORT(vec) sort(vec.begin(), vec.end()) #define RSORT(vec) sort(vec.rbegin(), vec.rend()) #define MIN(a, b) a = min(a, b) #define MAX(a, b) a = max(a, b) #define INF 1000000010 #define LL_INF 4500000000000000000LL #define LSOne(S) (S & (-S)) #define EPS 1e-9 #define pA first #define pB second #define mp make_pair #define pb push_back #define PI acos(-1.0) #define ll long long #define MOD (int)(2e+9+11) #define SET(vec, val, size) for (int i = 0; i < size; i++) vec[i] = val; #define SET2D(arr, val, dim1, dim2) F0R(i, dim1) F0R(j, dim2) arr[i][j] = val; #define SET3D(arr, val, dim1, dim2, dim3) F0R(i, dim1) F0R(j, dim2) F0R(k, dim3) arr[i][j][k] = val; #define SET4D(arr, val, dim1, dim2, dim3, dim4) F0R(i, dim1) F0R(j, dim2) F0R(k, dim3) F0R(l, dim4) arr[i][j][k][l] = val; #define READGRID(arr, dim) F0R(i, dim) F0R(j, dim) cin >> arr[i][j]; #define all(x) (x).begin(), (x).end() typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<iii> viii; typedef vector<ll> vl; void setupIO(const string &PROB = "") { ios::sync_with_stdio(false); cin.tie(nullptr); if (PROB.length() != 0) { ifstream infile(PROB + ".in"); if (infile.good()) { freopen((PROB + ".in").c_str(), "r", stdin); freopen((PROB + ".out").c_str(), "w", stdout); } } } /* ============================ */ int main() { setupIO(); int l, r, m; cin >> l >> r >> m; set<int> L[l], R[r]; vii children[l]; int ans[m]; F0R(i, m) { int a, b; cin >> a >> b; children[--a].pb(mp(--b, i)); } int maxColor = 0; F0R(i, l) { maxColor = max(maxColor, (int)children[i].size()); } int maxx = 1; while (maxx < maxColor) { maxx *= 2; } F0R(i, l) { for (ii u : children[i]) { while (true) { int c = rand() % maxx; if (L[i].count(c) || R[u.pA].count(c)) continue; L[i].insert(c); R[u.pA].insert(c); ans[u.pB] = c + 1; break; } } } cout << maxx << endl; F0R(i, m) cout << ans[i] << "\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

teoreticar.cpp: In function 'void setupIO(const string&)':
teoreticar.cpp:50:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
             freopen((PROB + ".in").c_str(), "r", stdin);
             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
teoreticar.cpp:51:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
             freopen((PROB + ".out").c_str(), "w", stdout);
             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...