Last active
April 13, 2019 20:12
-
-
Save jaideepheer/8c21a10bc90df4477384c0f3fdbd4657 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<bitset> | |
using namespace std; | |
int main() | |
{ | |
int N; | |
cin>>N; | |
unsigned int count[4096] = {0}; | |
long long inp; | |
long answer = 0; | |
for(int i=0; i<N; ++i) | |
{ | |
int hash = 0; | |
cin>>inp; | |
// hash digits | |
while(inp>0) | |
{ | |
hash |= 1<<(inp%10); | |
inp /= 10; | |
} | |
++count[hash]; | |
answer += count[hash ^ (0b1111111111)]; | |
//cout<<bitset<10>(hash)<<" | "<<bitset<10>(hash ^ (0b1111111111))<<endl; | |
} | |
cout<<answer<<endl; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.Comparator; | |
import java.util.List; | |
import java.util.Scanner; | |
class balak | |
{ | |
int marks; | |
int id; | |
String name; | |
public int getnamelen(){return this.name.length();} | |
public int getmark(){return this.marks;} | |
public int getid(){return this.id;} | |
@Override | |
public String toString() { | |
return "[Balak] id: "+this.id+", name: "+this.name+", marks: "+(-this.marks); | |
} | |
} | |
public class sort | |
{ | |
public static void main(String args[]) | |
{ | |
Scanner s = new Scanner(System.in); | |
List<balak> lols = new ArrayList<>(); | |
int N = s.nextInt(); | |
// memory alloc | |
for(int i=0;i<N;++i) | |
{ | |
lols.add(new balak()); | |
} | |
// Take input | |
for(int i=0;i<N;++i) lols.get(i).name = s.next(); | |
for(int i=0;i<N;++i) lols.get(i).marks = -s.nextInt(); | |
for(int i=0;i<N;++i) lols.get(i).id = s.nextInt(); | |
// sort | |
Comparator<balak> comp = Comparator.comparing(balak::getmark).thenComparing(balak::getnamelen).thenComparing(balak::getid); | |
lols.sort(comp); | |
for(int i=0;i<N;++i) | |
{ | |
System.out.println(lols.get(i)); | |
} | |
s.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment