제출 #558307

#제출 시각아이디문제언어결과실행 시간메모리
558307Yazan_AlattarIzlet (COI19_izlet)C++14
18 / 100
505 ms53520 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define F first #define S second #define pb push_back #define endl "\n" #define aint(x) x.begin(), x.end() const int M = 3007; const ll inf = 2e9; const ll mod = 1e9 + 7; const double pi = acos(-1); const double eps = 1e-6; const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0}; const int block = 320; vector <int> adj[M]; vector < pair <int,int> > ans; int n, a[M][M], sz[M][2], p[M][2], col[M]; void dfs(int node, int p){ for(auto i : adj[node]) if(i != p){ col[i] = col[node] ^ 1; dfs(i, node); } return; } int root(int x, int c){ while(p[x][c] != x){ p[x][c] = p[p[x][c]][c]; x = p[x][c]; } return x; } void connect(int x, int y, int c){ x = root(x, c); y = root(y, c); if(x == y) return; if(sz[x][c] > sz[y][c]) swap(x, y); p[x][c] = y; sz[y][c] += sz[x][c]; return; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int subtask; cin >> subtask; if(subtask == 1){ cin >> n; for(int i = 1; i <= n; ++i) for(int j = 0; j < 2; ++j) p[i][j] = i, sz[i][j] = 1; for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) cin >> a[i][j]; for(int i = 1; i <= n; ++i){ for(int j = 1; j <= n; ++j) if(root(i, 0) != root(j, 0) && a[i][j] == 1){ ans.pb({i, j}); connect(i, j, 0); connect(i, j, 1); } } for(int i = 1; i <= n; ++i){ for(int j = 1; j <= n; ++j) if(root(i, 1) != root(j, 1) && a[i][j] == 2){ adj[root(i, 0)].pb(root(j, 0)); adj[root(j, 0)].pb(root(i, 0)); ans.pb({i, j}); connect(i, j, 1); } } dfs(root(1, 0), 0); for(int i = 1; i <= n; ++i) cout << col[root(i, 0)] + 1 << " "; cout << endl; for(auto i : ans) cout << i.F << " " << i.S << endl; } return 0; }

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

izlet.cpp: In function 'int main()':
izlet.cpp:77:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   77 |         for(int i = 1; i <= n; ++i) cout << col[root(i, 0)]  + 1 << " "; cout << endl;
      |         ^~~
izlet.cpp:77:74: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   77 |         for(int i = 1; i <= n; ++i) cout << col[root(i, 0)]  + 1 << " "; cout << endl;
      |                                                                          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...