제출 #699497

#제출 시각아이디문제언어결과실행 시간메모리
699497Cross_RatioTeoretičar (COCI18_teoreticar)C++14
0 / 130
292 ms228316 KiB
#include <bits/stdc++.h> using namespace std; int num[500005]; array<int, 2> Edge[100005]; vector<int> adj[100005]; vector<int> adj2[100005]; int num_cnt = 0; int num1[100005]; int num2[100005]; bool pos[10005][10005]; signed main() { cin.sync_with_stdio(false); cin.tie(0); cout.tie(0); int L, R, M; cin >> L >> R >> M; int i, j; for(i=0;i<M;i++) { int a, b; cin >> a >> b; adj[a-1].push_back(b-1); adj2[b-1].push_back(a-1); Edge[i] = {a-1, b-1}; } for(i=0;i<=L;i++) { for(j=0;j<=10000;j++) pos[i][j] = true; } for(i=0;i<L;i++) { int cnt = 0; while(!pos[i][cnt]) cnt++; pos[i][cnt] = false; num1[i] = cnt; for(int j : adj[i]) { for(int k : adj2[j]) pos[k][cnt] = false; } } for(i=0;i<=R;i++) { for(j=0;j<=10000;j++) pos[i][j] = true; } for(j=0;j<R;j++) { int cnt = 0; while(!pos[j][cnt]) cnt++; pos[j][cnt] = false; num2[j] = cnt; for(int i : adj2[j]) { for(int k : adj[i]) pos[k][cnt] = false; } } vector<int> idx; for(i=0;i<M;i++) { idx.push_back(num1[Edge[i][0]]^num2[Edge[i][1]]); num[i] = num1[Edge[i][0]]^num2[Edge[i][1]]; } sort(idx.begin(),idx.end()); idx.erase(unique(idx.begin(),idx.end()),idx.end()); for(i=0;i<M;i++) { num[i] = lower_bound(idx.begin(),idx.end(),num[i]) - idx.begin(); } int madeg = 0; for(i=0;i<L;i++) madeg = max(madeg, (int)adj[i].size()); for(i=0;i<R;i++) madeg = max(madeg, (int)adj2[i].size()); int val = 1; for(;val<madeg;val*=2) {} assert(idx.size()<=2*val); cout << idx.size() << '\n'; for(i=0;i<M;i++) cout << num[i]+1 << '\n'; }

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

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from teoreticar.cpp:1:
teoreticar.cpp: In function 'int main()':
teoreticar.cpp:72:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   72 |     assert(idx.size()<=2*val);
      |            ~~~~~~~~~~^~~~~~~
#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...