QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#239892#7686. The Phantom Menaceucup-team197#Compile Error//C++172.6kb2023-11-05 00:16:502023-11-05 00:16:51

Judging History

你现在查看的是最新测评结果

  • [2024-10-08 14:11:03]
  • hack成功,自动添加数据
  • (/hack/941)
  • [2024-10-08 10:05:28]
  • hack成功,自动添加数据
  • (/hack/940)
  • [2024-10-07 19:51:15]
  • hack成功,自动添加数据
  • (/hack/938)
  • [2024-10-07 19:28:01]
  • hack成功,自动添加数据
  • (/hack/937)
  • [2024-10-07 17:16:32]
  • hack成功,自动添加数据
  • (/hack/936)
  • [2024-10-07 16:53:09]
  • hack成功,自动添加数据
  • (/hack/935)
  • [2024-10-07 16:22:17]
  • hack成功,自动添加数据
  • (/hack/934)
  • [2023-11-05 00:16:51]
  • 评测
  • [2023-11-05 00:16:50]
  • 提交

answer

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fi first
#define se second
ll n,m;
string a[1000005],b[1000005];
const ll base=2977;
void add(ull &x,char c){
    x = (x * base + c);
}
pair<int,int>g[1000005],h[1000005];

gp_hash_table<ll, ll> mp,mp1,mp2;
bool check0(){
	mp.clear();
	int sz=0;
	
	for(int i=1; i<=n ;i++){
		ull hsh = 0;
		for(auto c:a[i]) add(hsh,c);
		if(mp[hsh]==0) mp[hsh]=++sz;
		g[i]={mp[hsh],i};
	}
	for(int i=1; i<=n ;i++){
		ull hsh = 0;
		for(auto c:b[i]) add(hsh,c);
		if(mp[hsh]==0) mp[hsh]=++sz;
		h[i]={mp[hsh],i};
	}
	sort(g+1,g+n+1);sort(h+1,h+n+1);
	for(int i=1; i<=n ;i++) if(g[i].fi!=h[i].fi) return false;
	for(int i=1; i<=n ;i++) cout << g[i].se << ' ';
	cout << '\n';
	for(int i=1; i<=n ;i++) cout << h[i].se << ' ';
	cout << '\n';
	return true;
}

const int N=4e6+5;
vector<pair<int,int> >adj[N];
int in[N],out[N];
vector<int>ans;
void dfs(int id){
	//if(adj[id].empty()) return;
	while(!adj[id].empty()){
		auto c=adj[id].back();adj[id].pop_back();
		dfs(c.se);
		ans.push_back(c.fi);
	}
}
void adde(int u,int v,int w){
	//cout << "Adde " << u << ' ' << v << ' ' << w << endl;
	adj[u].push_back({w,v});
	out[u]++;in[v]++;
}
bool check(int p){
	//cout << "Check " << p << endl;
	mp1.clear();mp2.clear();
	int sz=0;
	for(int i=1; i<=4*n ;i++){
		adj[i].clear();
		in[i]=0;out[i]=0;
	}
	for(int i=1; i<=n ;i++){
		ull hsh = 0;
		for(int j=0; j<p ;j++) add(hsh,a[i][j]);
		if(mp1[hsh]==0) mp1[hsh]=++sz;
		int v1=mp1[hsh];
		
		hsh = 0;
		for(int j=p; j<m ;j++) add(hsh,a[i][j]);
		if(mp2[hsh]==0) mp2[hsh]=++sz;
		int v2=mp2[hsh];
		adde(v1,v2,i);
	}
	for(int i=1; i<=n ;i++){
		ull hsh = 0;
		for(int j=m-p; j<m ;j++) add(hsh,b[i][j]);
		if(mp1[hsh]==0) mp1[hsh]=++sz;
		int v1=mp1[hsh];
		
		hsh = 0;
		for(int j=0; j<m-p ;j++) add(hsh,b[i][j]);
		if(mp2[hsh]==0) mp2[hsh]=++sz;
		int v2=mp2[hsh];
		adde(v2,v1,i+n);
	}
	for(int i=1; i<=sz ;i++) if(in[i]!=out[i]) return false;
	ans.clear();
	dfs(1);
	if(ans.size()!=2*n) return false;
	reverse(ans.begin(),ans.end());
	for(int i=0; i<2*n ;i+=2) cout << ans[i] << ' ';
	cout << '\n';
	for(int i=1; i<2*n ;i+=2) cout << ans[i]-n << ' ';
	cout << '\n';
	return true;
}
void solve(){
	cin >> n >> m;
	for(int i=1; i<=n ;i++) cin >> a[i];
	for(int i=1; i<=n ;i++) cin >> b[i];
	if(check0()) return;
	for(int j=1; j<m ;j++){
		if(check(j)) return;
	}
	cout << "-1\n";
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	int t;cin >> t;while(t--) solve();
}

Details

answer.code:11:1: error: ‘string’ does not name a type
   11 | string a[1000005],b[1000005];
      | ^~~~~~
answer.code:16:1: error: ‘pair’ does not name a type
   16 | pair<int,int>g[1000005],h[1000005];
      | ^~~~
answer.code:18:1: error: ‘gp_hash_table’ does not name a type
   18 | gp_hash_table<ll, ll> mp,mp1,mp2;
      | ^~~~~~~~~~~~~
answer.code: In function ‘bool check0()’:
answer.code:20:9: error: ‘mp’ was not declared in this scope; did you mean ‘m’?
   20 |         mp.clear();
      |         ^~
      |         m
answer.code:25:28: error: ‘a’ was not declared in this scope
   25 |                 for(auto c:a[i]) add(hsh,c);
      |                            ^
answer.code:27:17: error: ‘g’ was not declared in this scope
   27 |                 g[i]={mp[hsh],i};
      |                 ^
answer.code:31:28: error: ‘b’ was not declared in this scope
   31 |                 for(auto c:b[i]) add(hsh,c);
      |                            ^
answer.code:33:17: error: ‘h’ was not declared in this scope
   33 |                 h[i]={mp[hsh],i};
      |                 ^
answer.code:35:14: error: ‘g’ was not declared in this scope
   35 |         sort(g+1,g+n+1);sort(h+1,h+n+1);
      |              ^
answer.code:35:9: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   35 |         sort(g+1,g+n+1);sort(h+1,h+n+1);
      |         ^~~~
      |         short
answer.code:35:30: error: ‘h’ was not declared in this scope
   35 |         sort(g+1,g+n+1);sort(h+1,h+n+1);
      |                              ^
answer.code:37:33: error: ‘cout’ was not declared in this scope
   37 |         for(int i=1; i<=n ;i++) cout << g[i].se << ' ';
      |                                 ^~~~
answer.code:1:1: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
  +++ |+#include <iostream>
    1 | // #include <bits/extc++.h>
answer.code:38:9: error: ‘cout’ was not declared in this scope
   38 |         cout << '\n';
      |         ^~~~
answer.code:38:9: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
answer.code: At global scope:
answer.code:45:1: error: ‘vector’ does not name a type
   45 | vector<pair<int,int> >adj[N];
      | ^~~~~~
answer.code:47:1: error: ‘vector’ does not name a type
   47 | vector<int>ans;
      | ^~~~~~
answer.code: In function ‘void dfs(int)’:
answer.code:50:16: error: ‘adj’ was not declared in this scope; did you mean ‘add’?
   50 |         while(!adj[id].empty()){
      |                ^~~
      |                add
answer.code:53:17: error: ‘ans’ was not declared in this scope
   53 |                 ans.push_back(c.fi);
      |                 ^~~
answer.code: In function ‘void adde(int, int, int)’:
answer.code:58:9: error: ‘adj’ was not declared in this scope; did you mean ‘add’?
   58 |         adj[u].push_back({w,v});
      |         ^~~
      |         add
answer.code: In function ‘bool check(int)’:
answer.code:63:9: error: ‘mp1’ was not declared in this scope
   63 |         mp1.clear();mp2.clear();
      |         ^~~
answer.code:63:21: error: ‘mp2’ was not declared in this scope
   63 |         mp1.clear();mp2.clear();
      |                     ^~~
answer.code:66:17: error: ‘adj’ was not declared in this scope; did you mean ‘add’?
   66 |                 adj[i].clear();
      |                 ^~~
      |                 add
answer.code:71:48: error: ‘a’ was not declared in this scope
   71 |                 for(int j=0; j<p ;j++) add(hsh,a[i][j]);
      |                                                ^
answer.code:76:48: error: ‘a’ was not declared in this scope
   76 |                 for(int j=p; j<m ;j++) add(hsh,a[i][j]);
      |                                                ^
answer.code:83:50: error: ‘b’ was not declared in this scope
   83 |                 for(int j=m-p; j<m ;j++) add(hsh,b[i][j]);
      |                                                  ^
answer.code:88:50: error: ‘b’ was not declared in this scope
   88 |                 for(int j=0; j<m-p ;j++) add(hsh,b[i][j]);
      |                                                  ^
answer.code:94:9: error: ‘ans’ was not declared in this scope
   94 |         ans.clear();
      |         ^~~
answer.code:97:9: error: ‘reverse’ was not declared in this scope
   97 |         reverse(ans.begin(),ans.end());
      |         ^~~~~~~
answer.code:98:35: error: ‘cout’ was not declared in this scope
   98 |         for(int i=0; i<2*n ;i+=2) cout << ans[i] << ' ';
      |                                   ^~~~
answer.code:98:35: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
answer.code:99:9: error: ‘cout’ was not declared in this scope
   99 |         cout << '\n';
      |         ^~~~
answer.code:99:9: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
answer.code: In function ‘void solve()’:
answer.code:105:9: error: ‘cin’ was not d...