이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <cmath>
#include <queue>
#include <set>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <unordered_set>
#define F first
#define S second
#define PB push_back
using namespace std;
const long long MOD=1e9+7, INF=1e18;
const int INFI=1e9;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<pair<int, ii>> viii;
typedef vector<vii> vvii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
/*
class UnionFind{
private:
vi p, rank;
public:
void build(int n){
p.assign(n, 0); for(int i=0;i<n;i++) p[i]=i;
rank.assign(n, 0);
}
int findSet(int i){ return (p[i]==i ? i : p[i]=findSet(p[i])); }
bool isSameSet(int i, int j){ return findSet(i)==findSet(j); }
void unionSet(int i, int j){
if(isSameSet(i, j)) return;
int x=findSet(i), y=findSet(j);
if(rank[x]>rank[y]) swap(x, y);
p[x]=y;
if(rank[x]==rank[y]) ++rank[y];
}
};
vector<UnionFind> UF;
*/
int n, k;
vector<vector<ll>> con;
void init(int N, int K){
n=N; k=K;
con.resize(n, vll(n/60+1, 0));
for(int i=0;i<k;i++)
for(int j=i;j<k;j++)
con[i][j/60]|=((ll)1<<(j%60));
}
int add_teleporter(int u, int v){
for(int i=0;i<con[u].size();i++)
con[u][i]|=con[v][i];
int cnt=0;
for(int i=0;i<k;i++){
if(con[u][i/60] & ((ll)1<<i)) cnt=true;
}
if(cnt) return 1;
else return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:62:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
62 | for(int i=0;i<con[u].size();i++)
| ~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |