Go: package main

import "fmt"

func main() {
    var n, m int
    fmt.Scan(&n)

    u := make([]string, 300)

    for i := 0; i < n; i++ {
        fmt.Scan(&u[i])
    }

    fmt.Scan(&m)

    is_lock := true
    for i := 0; i < m; i++ {
        var t string
        fmt.Scan(&t)

        is_include := false
        for j := 0; j < n; j++ {
            if t == u[j] {
                is_include = true
                break
            }
        }
        if is_include == false {
            fmt.Printf("Unknown %s\n", t)
        } else if (is_lock) {
            fmt.Printf("Opened by %s\n", t)
            is_lock = false
        } else {
            fmt.Printf("Closed by %s\n", t)
            is_lock = true
        }
    }
}

C++: #include<iostream>
#include<vector>
#include<queue>

using namespace std;

bool find(string str, vector<string> v){
	for (int i = 0; i < v.size(); i++){
		if (v[i] == str) return true;
	}
	return false;
}

int main(){
	int n; cin >> n;
	vector<string> regist(n);
	for (int i = 0 ; i < n; i++){
		cin >> regist[i];
	}
	bool lock = false;

	int m; cin >> m;
	for (int i = 0; i < m; i++){
		string id; cin >> id;
		if (find(id,regist) and !lock){
			cout << "Opened by " << id << endl;
		}else if (find(id,regist) and lock){
			cout << "Closed by " << id << endl;
		}else if (!find(id,regist)){
			cout << "Unknown " << id << endl;
		}
	}

return 0;
}

C++: #include<iostream>
using namespace std;int main(){string u[256],t;int n,m,i,j,f=0,k;cin>>n;for(i=0;i<n;i++)cin>>u[i];cin>>m;for(i=0;i<m;i++){cin>>t;k=f;for(j=0;j<n;j++)if(t==u[j]){if(f==0)f=1,cout<<"Opened by ";else f=0,cout<<"Closed by ";}if(k==f)cout<<"Unknown ";cout<<t<<endl;}return 0;}

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

int main(){
  int n;
  string s[300];
  while(cin>>n&&n){
    for(int i=0;i<n;i++) cin>>s[i];
    int m;
    cin>>m;
    bool p=0,np=0;
    while(m--){
      string str;
      cin>>str;
      for(int i=0;i<n;i++)
	if(str==s[i]){
	  np=!np;
	  break;
	}
      if(p==np) cout<<"Unknown "<<str<<endl;
      else if(np) {cout<<"Opened by "<<str<<endl;p=np;}
      else {cout<<"Closed by "<<str<<endl;p=np;}
    }
  }
  return 0;
}

C++: #include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int N, M;
string U[256];

int main() {
  char s[11];
  scanf("%d", &N);
  for (int i=0;i<N;i++) {
    scanf("%s", s);
    U[i] = s;
  }
  scanf("%d", &M);
  bool opened = false;
  for (int i=0;i<M;i++) {
    scanf("%s", s);
    const string* p = find(U, U+N, (string)s);
    if (p && !p->empty()) {
      opened = !opened;
      printf("%s by %s\n", (opened ? "Opened" : "Closed"), s);
    } else {
      printf("Unknown %s\n", s);
    }
  }
  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
using namespace std;

// s.....0=�{�� 1=����
int n, m, s = 0, c = 0;
char u[256][11] = {}, t[256][11] = {};

int check(int a, int b);

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", &u[i]);
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%s", &t[i]);
	}

	for (int i = 0; i < m; i++) {
		c = 0;

		for (int j = 0; j < n; j++) {
			if (check(j, i)) {
				c = 1;
				if (s == 0) {
					printf("Opened by %s\n", t[i]);
					s = 1;
					break;
				}
				if (s == 1) {
					printf("Closed by %s\n", t[i]);
					s = 0;
					break;
				}
			}
		}

		if (c == 0) {
			printf("Unknown %s\n", t[i]);
		}
	}
	return 0;
}

int check(int a, int b) {
	for (int i = 0; i < 10; i++) {
		if (u[a][i] != t[b][i])
			return 0;
		if (u[a][i] == t[b][i] && u[a][i] == 0)
			return 1;

	}
	//printf("fadsfasf");
	return 1;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin >> n;
	string u[n];
	for(int i=0;i<n;i++){
		cin >> u[i];
	}
	cin >> m;
	string t[m],kaku[m];
	int l=0;
	for(int i=0;i<m;i++){
		cin >> t[i];
		kaku[i]=t[i];
		for(int j=0;j<n;j++){
			l=0;
			for(int k=0;k<=i;k++){
				if(t[i]==kaku[k]){
					l++;
				}
			}
			if((t[i]==u[j]) && (l%2==1)){
				cout << "Opened by " << t[i];
				break;
			}else if((t[i]==u[j]) && (l%2==0)){
				cout << "Closed by " << t[i];
				break;
			}
			if(j==n-1){
				cout << "Unknown " << t[i];
				break;
			}
		}
		cout << endl;
	}
}

C++: #include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<string> U(N);
	for (int i = 0; i < N;i++) cin >> U[i];
	int M; cin >> M;
	bool lock = true;
	string T;
	for (int i = 0; i < M;i++) {
		cin >> T;
		if (find(U.begin(), U.end(), T) == U.end()) {
			cout << "Unknown " << T << endl;
		}
		else {
			if (!lock) {
				cout << "Closed by " << T << endl;
				lock = true;
			}
			else {
				cout << "Opened by " << T << endl;
				lock = false;
			}
		}
	}
}

C++: // AOJ 2440

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
	int n, m;
	string str;
	vector <string> keys;
	bool door = false;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> str;
		keys.push_back(str);
	}

	cin >> m;
	for (int i = 0; i < m; i++){
		cin >> str;
		bool know = false;
		for (int j = 0; j < n; j++){
			if (keys[j] == str){
				know = true;
			}
		}
		if (know){
			if (door){
				cout << "Closed by " << str << endl;
				door = false;
			}
			else {
				cout << "Opened by " << str << endl;
				door = true;
			}
		}
		else {
			cout << "Unknown " << str << endl;
		}
	}

	return 0;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	int N=read();
	string U[N];
	REP(i,N){
		cin >> U[i];
	}
	int M=read();
	string T[M];
	bool keyOpend = false; 
	REP(i,M){
		cin >> T[i];
		REP(j,N){
			if(T[i].compare(U[j])==0){
				if(keyOpend){
					cout << "Closed by " << T[i] << endl;
				}
				else{
					cout << "Opende by " << T[i] << endl;
				}
				keyOpend = !keyOpend;
				break;
			}
			if(j==N-1) cout << "Unknown " << T[i] << endl;
		}
	}
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int N;
	cin >> N;
	
	set< string > s;
	
	for_(i,0,N) {
		string str;
		cin >> str;
		s.insert(str);
	}
	
	int M;
	cin >> M;
	
	bool openf = false;
	
	for_(i,0,M) {
		string str;
		cin >> str;
		
		if (s.count(str)) {
			cout << (openf ? "Closed by " : "Opened by ") << str << endl;
			openf = !openf;
		} else {
			cout << "Unknown " << str << endl;
		}
	}
}

C++: #include <iostream>
#include <set>
#include <string>

using namespace std;

string message[] = {"Opened by ", "Closed by "};
int cnt;
int n, m;
set<string> registered;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        string str;
        cin >> str;
        registered.insert(str);
    }

    cin >> m;
    for (int i = 0; i < m; i++) {
        string str;
        cin >> str;
        if (registered.count(str) == 0) {
            cout << "Unknown " << str << endl;
        } else {
            cout << message[cnt % 2] << str << endl;
            cnt++;
        }
    }

    return 0;
}

C++: #include <stdio.h>
int main(){

  int n,m,i,j,c=0;

  char a[11][300];
  char b[11][300];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%s",a[i]);
  }


  scanf("%d",&m);

  for(j=1;j<=m;j++){
    scanf("%s",b[j]);
  }



  // for(i=1;i<=n;i++){
  // printf("%s\n",a[i]);
  //  }
  

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){

      if(strcmp(a[j],b[i])==0){
	c++;
	break;
      }
    }
     if(strcmp(a[j],b[i])!=0){
	printf("Unknown %s\n",b[i]);
      }
    
      if(c%2!=0){
	printf("Opened by %s\n",a[j]);
      }
      else{
	printf("Closed by %s\n",a[j]);
      }
  }




  return 0;
}