why CE?
  • 板块灌水区
  • 楼主ananzzx
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/8/25 21:32
  • 上次更新2024/8/26 09:00:14
查看原帖
why CE?
1038289
ananzzx楼主2024/8/25 21:32
#include <bits/stdc++.h>
#define int long long
#define int128 __int128

#define In(x) freopen(x ".in", "r", stdin)
#define Out(x) freopen(x ".out", "w", stdout)
#define File(x) (In(x), Out(x))

typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;

#define PII pii,vector<pii>,greater<pii>
#define mem(f, x) memset(f, x, sizeof(f))

#define kl k << 1
#define kr k << 1 | 1

//char buf[1<<20],*p1,*p2;
//#define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin), p1 == p2) ? 0 : *p1++)
#define gc() getchar()
#define pc(x) putchar(x)
#define spc putchar(' ')
#define ent putchar('\n')
#define endl '\n'

#define debug(x) cerr << #x << '=' << x << endl
#define line cerr << "\n---------------------------------------------------------\n"
#define cout cerr

using std::min;
using std::max;
using std::string;

const int INF = 0x3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

inline int pf(int x) { return x * x ; }
inline double DIS(int x1,int y1,int x2,int y2) { return sqrt( pf(x1-x2) + pf(y1-y2) ) ; }

inline int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
inline int lcm(int x, int y) { return x / gcd(x, y) * y; }
inline int Min(int a, int b, int c) { return min(a, min(b, c)); }
inline int Max(int a, int b, int c) { return max(a, max(b, c)); }
inline int lowbit(int x) { return x & -x ; }


namespace input{
    inline int read(){
        bool f = 1;
        int x = 0;
        char ch = gc();
        while ( ch < '0' || ch > '9' ){
            if (ch == '-') f =! f;
            ch = gc();
        }
        while ( ch >= '0' && ch <= '9' ){
            x = (x << 1) + (x << 3) + (ch ^ 48);
            ch = gc();
        }
        return f ? x : -x;
    }

    inline char readc(){
        char c = getchar();
        while(c == ' ' || c == '\n') c = getchar();
        return c;
    }

    inline void readC(char s[]){
        int tot = 0;
        char ch = getchar();
        while(ch == ' ' || ch == '\n') ch = getchar();
        while(ch != ' ' && ch != '\n') s[++tot] = ch,ch = getchar();
    }
    inline void readCL(char s[]){
        int tot = 0;
        char ch = getchar();
        while(ch == '\n') ch = getchar();
        while(ch != '\n') s[++tot] = ch,ch = getchar();
    }
    /*
    inline string readS(){
        char ch = getchar();
        string s;
        while(ch == ' ' || ch == '\n') ch = getchar();
        while(ch != ' ' && ch != '\n') s += ch , ch = getchar();
        return s;
    }*/
    inline void readS(string &s){
        char ch = getchar();
        s = "";
        while(ch == ' ' || ch == '\n') ch = getchar();
        while(ch != ' ' && ch != '\n') s += ch , ch = getchar();
    }
    inline string readSL(){
        string s;
        char ch = getchar();
        while(ch == '\n') ch = getchar();
        while(ch != '\n') s += ch,ch = getchar();
        return s;
    }

}

namespace output{
    inline void write(int x) {
        if (x < 0)
            putchar('-'), x = -x;
        if (x > 9)
            write(x / 10);
        putchar(x % 10 + '0');
    }

    inline void writeC(char s[],int l){
        for(int i = 1;i <= l;i++) putchar(s[i]);
    }

    inline void writeS(string s) {
        for (char i : s) putchar(i);
    }
}

using namespace std;
using namespace input;
using namespace output;

/***************************************************************************************************************************/
/**                                                                                                                       **/
/***************************************************************************************************************************/
const int MAXN = 250000 * 2 + 5;

string x,y;
map<string,int> mp;
int tot = 0;
int d[MAXN];
int fa[MAXN];
int find(int x){ return fa[x] == x ? x : fa[x] = find(fa[x]); }
void merge(int x,int y){
    int fx = find(x),fy = find(y);
    if(fx != fy) fa[fx] = fy;
}
signed main(){
    for(int i = 1;i <= 500000;i++) fa[i] = i;
    while(readS(x),readS(y)){
        if(mp[x] == 0) mp[x] = ++tot;
        if(mp[y] == 0) mp[y] = ++tot;
        int a = mp[x];
        int b = mp[y];
        d[a]++;d[b]++;
        merge(a,b);
    }
    for(int i = 1;i < tot;i++)
        if(find(i) != find(i+1)) return puts("Impossible"), 0;
    int cnt = 0;
    for(int i = 1;i <= tot;i++){
        if(d[i] & 1) cnt++;
    }
    if(cnt == 0 || cnt == 2) puts("Possible");
    else puts("Impossible");
    return 0;
}

2024/8/25 21:32
加载中...