Problem:
Problem C: Last One
Problem
あなたは、集合好きな友人Aと一風変わったゲームをしてみる事にした。
n個の要素からなる重複が許される非負の整数の集合Sが与えられる。集合Sに含まれる各要素は非負の
p
i
進数である。集合Sに対して
  以下のStep1~3を1つのターンとして、あなたと相手の二人が交互にターンを繰り返す。各ターンではこの番号の順に操作を行う。
Step 1: 集合Sに含まれる全ての要素を一度取り除き、その取り除いた各要素を2進数に変換して、0を消して1が1つ以上連続する部分に分割し、その分割された部分を全て集合Sに加える。
Step 2: このとき集合Sが空になっていたならば、現在このターンをプレイしているプレイヤーは負ける。
Step 3: 集合Sに含まれる要素aを1つ選び、そのaから 1 ≤ x ≤ a を満たす任意の整数xを引く。
下の図は次の入力が与えられたときの最初の1ターンの進行の仕方のうちの1つの例である。
4
10 3
2 11
16 5
16 AE
最初はあなたのターンだ。与えられた入力に対して両者が最善を尽くすとき、果たしてあなたに勝ち目はあるのだろうか。
Input
入力は次の形式で与えられる。
n
p
1
m
1
p
2
m
2
...
p
i
m
i
...
p
n
m
n
集合の要素である
p
i
進数
m
i
が
n
個与えられる。集合の要素の数
n
は10
5
を超えない。また、2≦
p
i
≦62を満たす。
p
i
進数
m
i
は通常の数字である0~9に加え、アルファベット52文字を使用する。
その順番は012...789ABC...XYZabc...xyzを昇順とし、
i
番目までの文字を使うものとする。また、
p
i
進数
m
i
は10進数で2
18
-1を超えない.
Output
与えられた入力に対しあなたが勝てるならwin、負けるならloseを出力せよ。
Sample Input 1
1
10 1
Sample Output 1
win
Sample Input 2
2
10 1
10 1
Sample Output 2
lose
Sample Input 3
3
25 53AI
43 3BI0
62 pn6
Sample Output 3
win

Submitted solutions:

code_snippet: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int ctoi(char c){
    if('A' <= c && c <= 'Z'){
        return c - 'A' + 10;
    }else if('a' <= c && c <= 'z'){
        return c - 'a' + 36;
    }
    return (int)c - '0';
}

int conv(int p, string m){
    int ret = 0;
    for(auto c : m){
        ret *= p;
        ret += ctoi(c);
    }

    return ret;
}

int main(){
    int n;
    cin >> n;

    int grundy = 0;

    for(int i = 0 ; i < n ; ++i){
        int p;
        string m;
        cin >> p >> m;

        grundy ^= conv(p, m);
    }

    if(grundy == 0){
        cout << "lose" << endl;
    }else{
        cout << "win" << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3440
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;

int n, p, now = 0;
string m;

void management();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> p >> m;
    management();
  }
  if(now == 0)
    cout << "lose" << endl;
  else
    cout << "win" << endl;
  return 0;
}

void management() {
  int tennum = 0, cnt = 0;
  for(int i = 0; i < m.size(); ++i) {
    tennum *= p;
    if(m[i] >= '0' && m[i] <= '9')
      tennum += m[i] - '0';
    else if(m[i] >= 'A' && m[i] <= 'Z')
      tennum += m[i] - 'A' + 10;
    else
      tennum += m[i] - 'a' + 36;
  }
  for(int i = 0; (1 << i) <= tennum; ++i) {
    if(((1 << i) & tennum) == (1 << i))
      now ^= (1 << cnt++);
    else
      cnt = 0;
  }
}
accuracy: 1
time_ms: 40
memory_kb: 3192
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int cv(char c){
    if(isdigit(c)) return c-'0';
    if(isupper(c)) return 10+c-'A';
    return 36+c-'a';
}

int READ(){
    int p;
    string m;
    cin >>p >>m;

    int ret = 0;
    for(char c:m) ret = ret*p + cv(c);
    return ret;
}

int main(){
    int n;
    cin >>n;

    int g = 0;
    rep(i,n) g ^= __builtin_popcount(READ());
    cout << (g==0?"lose":"win") << endl;
    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 3184
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

#define long long long // for codeforces

map<char,int> conv;

int main(){
  int cnt = 0;
  rep(i,10) conv['0' + i] = cnt++;
  rep(i,26) conv['A' + i] = cnt++;
  rep(i,26) conv['a' + i] = cnt++;

  vector<int> g(1<<19, 0);
  g[1] = 1;
  int mex = 2;
  rep(i,2,1<<19){
    g[i] = 0;
    int tmp = i;
    while(tmp > 0){
      while(tmp%2 == 0) tmp /= 2;
      int cur = 1;
      while(tmp%2==1){
        tmp /= 2;
        cur = cur*2 + 1;
      }
      cur /= 2;
      g[i] = g[i] ^ g[cur];
      if(i == cur) {
        g[i] = mex++;
      }
    }
    if(i<20) dbg(g[i]);
  }

  int ans = 0;
  int n;
  scanf("%d", &n);
  rep(i,n){
    int p;
    char s[100];
    scanf("%d %s", &p, s);
    int num = 0;
    for(int j = 0; s[j] != '\0'; j++){
      num = num * p + conv[s[j]];
    }
    ans = ans ^ g[num];
  }

  cout << (ans == 0 ? "lose" : "win") << endl;

  return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 4776
final_rank: 14

code_snippet: #include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N;
  cin >> N;
  vector<ll> S(N);
  REP(i, 0, N) {
    ll P;
    string M;
    cin >> P >> M;
    ll x = 0;
    REP(j, 0, M.size()) {
      char c = M[j];
      if('0' <= c && c <= '9') x = x * P + (c - '0');
      if('A' <= c && c <= 'Z') x = x * P + (c - 'A' + 10);
      if('a' <= c && c <= 'z') x = x * P + (c - 'a' + 10 + 'Z' - 'A' + 1);
    }
    S[i] = x;
  }

  ll g = 0;
  REP(i, 0, N) g = g ^ S[i];
  cout << (g != 0 ? "win" : "lose") << endl;
}
accuracy: 1
time_ms: 50
memory_kb: 3620
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int cv(char c){
    if(isdigit(c)) return c-'0';
    if('A'<=c && c<='Z') return c-'A'+10;
    return c-'a'+36;
}

ll READ(){
    ll p;
    string s;
    cin >>p >>s;

    ll ret = 0;
    rep(i,s.size()){
        ret = p*ret + cv(s[i]);
    }
    return ret;
}

int main(){
    int n;
    cin >>n;

    vector<ll> x(n);
    rep(i,n) x[i] = READ();

    // rep(i,n) printf(" %lld\n", x[i]);
    ll res = 0;
    rep(i,n){
        res ^= __builtin_popcount(x[i]);
    }

    string ans = "lose";
    if(res != 0) ans = "win";
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3696
final_rank: 6

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int tonum(char c){
	if('0'<=c && c<='9') return c-'0';
	if('A'<=c && c <='Z') return c-'A'+10;
	return c-'a'+36;
}

int conv(int p, string s){
	int res=0;
	int base = 1;
	for(int i=s.length()-1; i>=0; i--, base*=p){
		res += tonum(s[i])*base;
	}
	return res;
}

vector<int> split(int a){
	vector<int> res;
	int con=0;
	for(int i=0; i<20; i++){
		if((1<<i & a) != 0){
			con++;
		}else if(con != 0){
			res.push_back(con);
			con = 0;
		}
	}
	return res;
}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		int p;
		string s;
		cin >> p >> s;
		a[i] = conv(p, s);
	}
	
	vector<int> len;
	for(int i=0; i<(int)a.size(); i++){
		vector<int> tmp = split(a[i]);
		len.insert(len.end(), tmp.begin(), tmp.end());
	}
	
	int g=0;
	for(int i=0; i<n; i++){
		g ^= len[i];
	}
	if(g==0){
		cout << "lose" << endl;
	}else{
		cout << "win" << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 7048
final_rank: 15

code_snippet: #include <iostream>
#include <cstring>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
int n;
ll sect[100005];
ll ans=0,tmpans=0;
ll tmpmin=1e12;
typedef long long ll;
typedef vector<ll> vll;

int main(int argc,char const* argv[])
{
  int n;
  int p[100005];
  string m[100005];
  int buckets[300000];
  memset(buckets,0,sizeof(buckets));
  cin >> n;
  for(int i=0;i<n;i++)
    {
      cin >> p[i] >> m[i];
    }
  for(int i=0;i<n;i++)
    {
      int tmp=0;
      int keta=1;
      for(int j=m[i].size()-1;j>=0;j--)
	{
	  //cout << (int)m[i][j] << endl;
	  if((int)m[i][j]<=57)
	    {
	      tmp+=(int)(m[i][j]-'0')*keta;
	    }
	  else if(65 <=(int)m[i][j] && (int)m[i][j]<=90)
	    {
	      tmp+=(10+(int)(m[i][j]-'A'))*keta;
	    }
	    else if(97 <=(int)m[i][j])
	    {
	      tmp+=(36+(int)(m[i][j]-'a'))*keta;
	    }
	  keta*=p[i];
	}
      int onedev=0;
      while(tmp!=0)
	{
	  if(tmp%2!=0) onedev++;
	  tmp/=2;
	}
      if(onedev==1) buckets[1]++;
      //buckets[tmp]++;
    }
  if(buckets[1]==n)
    {
      if(n%2==0)
	{
	  cout << "lose" << endl;
	}
      else
	{
	  cout << "win" << endl;
	}
    }
  else if(buckets[1]!=n)
    {
      if(buckets[1]%2!=0)
	{
	  cout << "lose" << endl;
	}
      else
	{
	  cout << "win" << endl;
	}
    }
  return 0;
}
accuracy: 0.2
time_ms: 30
memory_kb: 7812
final_rank: 20

code_snippet: #include <iostream>
#include <cstring>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
int n;
ll sect[100005];
ll ans=0,tmpans=0;
ll tmpmin=1e12;
typedef long long ll;
typedef vector<ll> vll;

int main(int argc,char const* argv[])
{
  int n;
  int p[100005];
  string m[100005];
  int buckets[300000];
  memset(buckets,0,sizeof(buckets));
  vi s;
  cin >> n;
  for(int i=0;i<n;i++)
    {
      cin >> p[i] >> m[i];
    }
  for(int i=0;i<n;i++)
    {
      int tmp=0;
      int keta=1;
      for(int j=m[i].size()-1;j>=0;j--)
	{
	  //cout << (int)m[i][j] << endl;
	  if((int)m[i][j]<=57)
	    {
	      tmp+=(int)(m[i][j]-'0')*keta;
	    }
	  else if(65 <=(int)m[i][j] && (int)m[i][j]<=90)
	    {
	      tmp+=(10+(int)(m[i][j]-'A'))*keta;
	    }
	    else if(97 <=(int)m[i][j])
	    {
	      tmp+=(36+(int)(m[i][j]-'a'))*keta;
	    }
	  keta*=p[i];
	}
      s.push_back(tmp);
      buckets[tmp]++;
    }
  if(buckets[1]==n)
    {
      if(n%2==0)
	{
	  cout << "lose" << endl;
	}
      else
	{
	  cout << "win" << endl;
	}
    }
  else if(buckets[1]!=n)
    {
      if(buckets[1]%2!=0)
	{
	  cout << "lose" << endl;
	}
      else
	{
	  cout << "win" << endl;
	}
    }
  return 0;
}
accuracy: 0.6
time_ms: 40
memory_kb: 10556
final_rank: 18

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int tonum(char c){
	if('0'<=c && c<='9') return c-'0';
	if('A'<=c && c <='Z') return c-'A'+10;
	return c-'a'+36;
}

int conv(int p, string s){
	int res=0;
	int base = 1;
	for(int i=s.length()-1; i>=0; i--, base*=p){
		res += tonum(s[i])*base;
	}
	return res;
}

vector<int> split(int a){
	vector<int> res;
	int con=0;
	for(int i=0; i<20; i++){
		if((1<<i & a) != 0){
			con++;
		}else if(con != 0){
			res.push_back((1<<con) -1);
			con = 0;
		}
	}
	return res;
}

vector<int> memo(1<<18, -1);
int grundy(int n){
	if(memo[n] != -1) return memo[n];
	vector<int> s = split(n);
	vector<int> g;
	for(int i=0; i<(int)s.size(); i++){
		for(int j=0; j<s[i]; j++){
			g.push_back(grundy(j));
		}
	}
	sort(g.begin(), g.end());
	int res=0;
	for(int i=0; i<(int)g.size(); i++){
		if(g[i] != res) break;
		res++;
	}
	memo[n] = res;
	return res;
}

int main(){
	memo[0] = 0;
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		int p;
		string s;
		cin >> p >> s;
		a[i] = conv(p, s);
	}
	
	int g=0;
	for(int i=0; i<n; i++){
		g ^= grundy(a[i]);
	}
	if(g==0){
		cout << "lose" << endl;
	}else{
		cout << "win" << endl;
	}
	return 0;
}
accuracy: 0.25
time_ms: 130
memory_kb: 4724
final_rank: 19

code_snippet: #include<bits/stdc++.h>
using namespace std;

long long po(long long p, long long n){
    long long res = 1;
    for(int i = 0; i < n; i++){
        res *= p;
    }

    return res;
}

int main(){    

    long long n; cin >> n;
    vector<long long> a(n);

    for(int ii = 0; ii < n; ii++){
        int p; cin >> p;
        string m; cin >> m;
        
        long long num = 0;
        int len = (int)m.size();
        for(int i = 0; i < len; i++){
            int idx = len - 1 - i;
            char c = m[idx];
            long long aa;
            if('A' <= c && c <= 'Z') aa = (long long)(10 + c - 'A');
            else if('a' <= c && c <= 'Z') aa = (long long)(36 + c - 'Z');
            else aa = (long long)(c - '0');
        
            a[ii] += aa * po(p, i);
        }
    }

    /*for(int i = 0; i < n; i++){
        cout << a[i] << endl;
    }*/

    int num = 0;
    for(int i = 0; i < n; i++){
        bool is_pre = false;
        while(a[i] != 0){
            if(a[i] % 2 == 1){
                num++;
                if(is_pre == true){
                    cout << "win" << endl;
                    return 0;
                }
                a[i] /= 2;
                is_pre = true;
            }else{
                is_pre = false;
                a[i] /= 2;
            }
        }
    }

    if(num % 2 == 1) cout << "win" << endl;
    else cout << "lose" << endl;
    return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 3644
final_rank: 13

code_snippet: #include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int decode(int p, string s) {
  // reverse(s.begin(), s.end());

  int ret = 0;
  for(int i=0; i<s.length(); i++) {
    ret *= p;

    int val = 0;
    if('0' <= s[i] && s[i] <= '9') {
      val += (s[i] - '0');
    }
    else if('A' <= s[i] && s[i] <= 'Z') {
      val += 10;
      val += (s[i] - 'A');
    }
    else {
      val += 10 + 26;
      val += (s[i] - 'a');
    }

    ret += val;
  }

  // printf("debug: p = %d, m = %s, result = %d\n", p, s.c_str(), ret);
  return ret;
}

void apply_num(int &res, int value) {
  int cons = 0;
  for(int i=0; i<20; i++, value >>= 1) {
    if(value & 1) cons++;
    else {
      res ^= cons;
      cons = 0;
    }
  }
}

int main() {
  int N; cin >> N;

  vector<int> P(N);
  vector<string> M(N);

  for(int i=0; i<N; i++) {
    cin >> P[i] >> M[i];
  }

  int res = 0;
  vector<int> V(N);
  for(int i=0; i<N; i++) {
    V[i] = decode(P[i], M[i]);
    apply_num(res, V[i]);
  }

  if(res != 0) cout << "win" << endl;
  else cout << "lose" << endl;
  return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 9264
final_rank: 17

code_snippet: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll getNUM(char ch){
	if(ch >= '0' && ch <= '9'){
		return ch-'0';
	}else if(ch >= 'A' && ch <= 'Z'){
		return 10+(ch-'A');
	}else{
		return 35+(ch-'a');
	}
}


ll calc(ll P,char buf[20]){

	ll ret = 0;

	for(int i = 0; buf[i] != '\0'; i++){
		ret += getNUM(buf[i]);
	}

	return ret;
}


int main(){

	int N;
	scanf("%d",&N);

	ll NIM = 0,P;
	char buf[20];

	for(int loop = 0; loop < N; loop++){
		scanf("%lld %s",&P,buf);
		NIM ^= calc(P,buf);
	}

	if(NIM == 0){
		printf("lose\n");
	}else{
		printf("win\n");
	}

	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3164
final_rank: 1

code_snippet: #include <bits/stdc++.h>

using namespace std;

int to_num(char c)
{
    if (isdigit(c)) {
        return c - '0';
    } else if (isupper(c)) {
        return c - 'A' + 10;
    } else {
        return c - 'a' + 36;
    }
}

int change(int p, string m)
{
    int res = 0;
    reverse(m.begin(), m.end());
    for (int i = 0; i < (int)m.size(); i++) {
        res += to_num(m[i]) * pow(p, i);
    }
    return res;
}

int main()
{
    int N, p, x = 0;
    string m;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> p >> m;
        x ^= change(p, m);
    }
    cout << (x != 0 ? "win" : "lose") << endl;
    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 3368
final_rank: 9

code_snippet: #include<iostream>
#include<string>
using namespace std;
char C[63] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
int convert(int p, string S) {
	int power[20]; power[0] = 1; for (int i = 1; i <= S.size(); i++)power[i] = power[i - 1] * p;
	int cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < p; j++) {
			if (C[j] != S[i])continue;
			cnt += power[S.size() - 1 - i] * j;
		}
	}
	return cnt;
}
int main() {
	int n; cin >> n; int W = 0;
	for (int i = 0; i < n; i++) {
		string U; int a; cin >> a >> U; a = convert(a, U);
		W ^= a;
	}
	if (W == 0)cout << "lose" << endl;
	else cout << "win" << endl;
	return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 3156
final_rank: 11

code_snippet: #include <string>
#include <iostream>
using namespace std;
int n, p; string s;
string w = "0123456789ABCDEFGHIJJKMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
int main() {
	cin >> n;
	int ret = 0;
	while (n--) {
		cin >> p >> s;
		long long t = 0;
		for (int i = 0; i < s.size(); i++) {
			t *= p;
			for (int j = 0; j < p; j++) {
				if (s[i] == w[j]) t += j;
			}
		}
		int cnt = 0;
		while (t > 0) t >>= 1, cnt++;
		ret ^= cnt;
	}
	cout << (ret ? "win" : "lose") << endl;
	return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 3160
final_rank: 7

code_snippet: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N; cin >> N;
	map<int, int>mp;
	for (int i = 0; i < N; ++i) {
		int p; string m; cin >>p>> m;
		long long int num = 0;
		for (auto c : m) {
			num *= p;
			if (isdigit(c)) {
				num += c - '0';
			}
			else if (c >= 'A'&&'Z' <= c) {
				num += c - 'A' + 10;
			}
			else {
				num += c - 'a' + 36;
			}
		}
		bitset<100>bs(num);
		int n = 0;
		for (int i = 0; i < 99; ++i) {
			if (bs[i]) {
				n++;
			}
			else {
				if (n) {
					mp[n]++;
					n = 0;
				}
			}
		}
	}
	int k = 0;
	for (auto m: mp) {
		if (m.second%2) {
			k ^= m.first;
		}
	}
	if (k)cout << "win" << endl;
	else cout << "lose" << endl;
	return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 3168
final_rank: 12

code_snippet: #include<bits/stdc++.h>
#define N 100000
using namespace std;

int stoi(char c){
  if('A'<=c&&c<='Z')return c-'A'+10;
  if('a'<=c&&c<='z')return c-'a'+36;
  return c-'0';
}

int main(){
  int n,p,num,ans=0;
  string m;
  cin>>n;
  while(n--){
    cin>>p>>m;
    num=0;
    for(int i=0;i<m.size();i++)
      num=num*p+stoi(m[i]);
    ans^=num;
  }
  if(ans)cout<<"win"<<endl;
  else cout<<"lose"<<endl;
  return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 1200
final_rank: 2

code_snippet: #include<bits/stdc++.h>
using namespace std;

int n,ans;
vector<int> V;

int change(char ch){
  if('0'<=ch&&ch<='9')return ch-'0';
  if('A'<=ch&&ch<='Z')return 10+ch-'A';
  return 36+ch-'a';
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    int p,num=0;
    string m;
    cin>>p>>m;
    for(int i=0;i<(int)m.size();i++)
      num=num*p+change(m[i]);
    ans^=num;
    V.push_back(num);
  }
  if(n==1 && V[0]==5){
    assert(0);
  }
  if(ans)cout<<"win"<<endl;
  else cout<<"lose"<<endl;
  return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 1708
final_rank: 5

code_snippet: #include<bits/stdc++.h>
using namespace std;

int getNum(char c){
  if('A'<=c&&c<='Z')return 10+c-'A';
  if('a'<=c&&c<='z')return 36+c-'a';
  return c-'0';
}

int pto10(int p,string s){
  int res=0,x=1;
  for(int i=0;i<s.size();i++)res+=x*getNum(s[i]),x*=p;
  return res;
}

int Cnt(int num){
  int res=0;
  while(num)res++,num/=2;
  return res;
}

int main(){
  int n,p,cnt1=0,cnt2=0;
  vector<int> v;
  string s;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>p>>s;
    reverse(s.begin(),s.end());
    int num=pto10(p,s),t=0;
    while(num){
      if(num%2)t=t*10+1;
      else v.push_back(t),t=0;
      num/=2;
    }
    v.push_back(t);
  }
  for(int i=0;i<v.size();i++){
    int cnt=Cnt(v[i]);
    if(!v[i])continue;
    if(cnt==1)cnt1++;
    else cnt2++;
  }
  if(cnt2||cnt1%2)cout<<"win"<<endl;
  else cout<<"lose"<<endl;
  return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 7284
final_rank: 16